Index: modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGenerator_ImplTest.java =================================================================== --- modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGenerator_ImplTest.java (revision 0) +++ modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGenerator_ImplTest.java (working copy) @@ -19,7 +19,7 @@ * @version $Revision$ */ -package javax.crypto; +package org.apache.harmony.crypto.tests.javax.crypto; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; @@ -31,6 +31,8 @@ import java.security.spec.AlgorithmParameterSpec; import java.security.spec.InvalidKeySpecException; +import javax.crypto.KeyGenerator; + import org.apache.harmony.security.SpiEngUtils; import junit.framework.TestCase; @@ -78,15 +80,6 @@ Security.removeProvider(mProv.getName()); } - /** - * Constructor for SecurityManagerFactoryTest2. - * - * @param arg0 - */ - public KeyGenerator_ImplTest(String arg0) { - super(arg0); - } - private void checkResult(KeyGenerator keyGen) { AlgorithmParameterSpec paramsNull = null; AlgorithmParameterSpec params = new APSpec(); Index: modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_ImplTest.java =================================================================== --- modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_ImplTest.java (revision 0) +++ modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_ImplTest.java (working copy) @@ -1,271 +1,265 @@ -/* - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package javax.crypto; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.Security; -import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.InvalidKeySpecException; - -import org.apache.harmony.security.SpiEngUtils; -import junit.framework.TestCase; - - -/** - * Tests for KeyAgreement class constructors and methods - * - */ - -public class KeyAgreement_ImplTest extends TestCase { - - private static final String srvKeyAgreement = "KeyAgreement"; - - private static final String defaultAlg = "MyKeyAgr"; - - private static final String KeyAgreementProviderClass = "org.apache.harmony.crypto.tests.support.MyKeyAgreementSpi"; - - private static final String[] invalidValues = SpiEngUtils.invalidValues; - - private static final String[] validValues; - - static { - validValues = new String[4]; - validValues[0] = defaultAlg; - validValues[1] = defaultAlg.toLowerCase(); - validValues[2] = "myKeyagr"; - validValues[3] = "mYkeYAGR"; - } - - Provider mProv; - - protected void setUp() throws Exception { - super.setUp(); - mProv = (new SpiEngUtils()).new MyProvider("MyKAProvider", "Testing provider", - srvKeyAgreement.concat(".").concat(defaultAlg), - KeyAgreementProviderClass); - Security.insertProviderAt(mProv, 1); - } - - /** - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - Security.removeProvider(mProv.getName()); - } - - /** - * Constructor for SecurityManagerFactoryTest2. - * - * @param arg0 - */ - public KeyAgreement_ImplTest(String arg0) { - super(arg0); - } - - protected void checkResult(KeyAgreement keyAgr) - throws InvalidKeyException, ShortBufferException, - NoSuchAlgorithmException, IllegalStateException, - InvalidAlgorithmParameterException { - assertNull("Not null result", keyAgr.doPhase(null, true)); - try { - keyAgr.doPhase(null, false); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - byte[] bb = keyAgr.generateSecret(); - assertEquals("Length is not 0", bb.length, 0); - assertEquals("Returned integer is not 0", - keyAgr.generateSecret(new byte[1], 10), - -1); - assertNull("Not null result", keyAgr.generateSecret("aaa")); - try { - keyAgr.generateSecret(""); - fail("NoSuchAlgorithmException must be throwm"); - } catch (NoSuchAlgorithmException e) { - } - Key key = null; - try { - keyAgr.init(key, new SecureRandom()); - fail("IllegalArgumentException must be throwm"); - } catch (IllegalArgumentException e) { - } - AlgorithmParameterSpec params = null; - try { - keyAgr.init(key, params, new SecureRandom()); - fail("IllegalArgumentException must be throwm"); - } catch (IllegalArgumentException e) { - } - } - - /** - * Test for getInstance(String algorithm) method - * Assertions: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is incorrect; - * returns KeyAgreement object - */ - public void testGetInstance01() throws NoSuchAlgorithmException, - InvalidKeySpecException, InvalidKeyException, - ShortBufferException, InvalidAlgorithmParameterException { - try { - KeyAgreement.getInstance(null); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyAgreement.getInstance(invalidValues[i]); - fail("NoSuchAlgorithmException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - KeyAgreement keyAgr; - for (int i = 0; i < validValues.length; i++) { - keyAgr = KeyAgreement.getInstance(validValues[i]); - assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(), - validValues[i]); - assertEquals("Incorrect provider", keyAgr.getProvider(), mProv); - checkResult(keyAgr); - } - } - /** - * Test for getInstance(String algorithm, String provider) - * method - * Assertions: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is null or incorrect; - * throws IllegalArgumentException when provider is null or null; - * throws NoSuchProviderException when provider is available; - * returns KeyAgreement object - */ - public void testGetInstance02() throws NoSuchAlgorithmException, - NoSuchProviderException, IllegalArgumentException, - InvalidKeySpecException, InvalidKeyException, - ShortBufferException, InvalidAlgorithmParameterException { - try { - KeyAgreement.getInstance(null, mProv.getName()); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyAgreement.getInstance(invalidValues[i], mProv - .getName()); - fail("NoSuchAlgorithmException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - String prov = null; - for (int i = 0; i < validValues.length; i++) { - try { - KeyAgreement.getInstance(validValues[i], prov); - fail("IllegalArgumentException must be thrown when provider is null (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (IllegalArgumentException e) { - } - try { - KeyAgreement.getInstance(validValues[i], ""); - fail("IllegalArgumentException must be thrown when provider is empty (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (IllegalArgumentException e) { - } - for (int j = 1; j < invalidValues.length; j++) { - try { - KeyAgreement.getInstance(validValues[i], - invalidValues[j]); - fail("NoSuchProviderException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(" provider: ") - .concat(invalidValues[j]).concat(")")); - } catch (NoSuchProviderException e) { - } - } - } - KeyAgreement keyAgr; - for (int i = 0; i < validValues.length; i++) { - keyAgr = KeyAgreement.getInstance(validValues[i], mProv - .getName()); - assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(), - validValues[i]); - assertEquals("Incorrect provider", keyAgr.getProvider().getName(), - mProv.getName()); - checkResult(keyAgr); - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) - * method - * Assertions: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is null or incorrect; - * throws IllegalArgumentException when provider is null; - * returns KeyAgreement object - * - */ - public void testGetInstance03() throws NoSuchAlgorithmException, - IllegalArgumentException, - InvalidKeySpecException, InvalidKeyException, - ShortBufferException, InvalidAlgorithmParameterException { - try { - KeyAgreement.getInstance(null, mProv); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - KeyAgreement.getInstance(invalidValues[i], mProv); - fail("NoSuchAlgorithmException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - Provider prov = null; - for (int i = 0; i < validValues.length; i++) { - try { - KeyAgreement.getInstance(validValues[i], prov); - fail("IllegalArgumentException must be thrown when provider is null (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (IllegalArgumentException e) { - } - } - KeyAgreement keyAgr; - for (int i = 0; i < validValues.length; i++) { - keyAgr = KeyAgreement.getInstance(validValues[i], mProv); - assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(), - validValues[i]); - assertEquals("Incorrect provider", keyAgr.getProvider(), mProv); - checkResult(keyAgr); - } - } -} +/* + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* @author Vera Y. Petrashkova +* @version $Revision$ +*/ + +package org.apache.harmony.crypto.tests.javax.crypto; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Provider; +import java.security.SecureRandom; +import java.security.Security; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.InvalidKeySpecException; + +import javax.crypto.KeyAgreement; +import javax.crypto.ShortBufferException; + +import org.apache.harmony.security.SpiEngUtils; +import junit.framework.TestCase; + + +/** + * Tests for KeyAgreement class constructors and methods + * + */ + +public class KeyAgreement_ImplTest extends TestCase { + + private static final String srvKeyAgreement = "KeyAgreement"; + + private static final String defaultAlg = "MyKeyAgr"; + + private static final String KeyAgreementProviderClass = "org.apache.harmony.crypto.tests.support.MyKeyAgreementSpi"; + + private static final String[] invalidValues = SpiEngUtils.invalidValues; + + private static final String[] validValues; + + static { + validValues = new String[4]; + validValues[0] = defaultAlg; + validValues[1] = defaultAlg.toLowerCase(); + validValues[2] = "myKeyagr"; + validValues[3] = "mYkeYAGR"; + } + + Provider mProv; + + protected void setUp() throws Exception { + super.setUp(); + mProv = (new SpiEngUtils()).new MyProvider("MyKAProvider", "Testing provider", + srvKeyAgreement.concat(".").concat(defaultAlg), + KeyAgreementProviderClass); + Security.insertProviderAt(mProv, 1); + } + + /** + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + Security.removeProvider(mProv.getName()); + } + + protected void checkResult(KeyAgreement keyAgr) + throws InvalidKeyException, ShortBufferException, + NoSuchAlgorithmException, IllegalStateException, + InvalidAlgorithmParameterException { + assertNull("Not null result", keyAgr.doPhase(null, true)); + try { + keyAgr.doPhase(null, false); + fail("IllegalStateException must be thrown"); + } catch (IllegalStateException e) { + } + byte[] bb = keyAgr.generateSecret(); + assertEquals("Length is not 0", bb.length, 0); + assertEquals("Returned integer is not 0", + keyAgr.generateSecret(new byte[1], 10), + -1); + assertNull("Not null result", keyAgr.generateSecret("aaa")); + try { + keyAgr.generateSecret(""); + fail("NoSuchAlgorithmException must be throwm"); + } catch (NoSuchAlgorithmException e) { + } + Key key = null; + try { + keyAgr.init(key, new SecureRandom()); + fail("IllegalArgumentException must be throwm"); + } catch (IllegalArgumentException e) { + } + AlgorithmParameterSpec params = null; + try { + keyAgr.init(key, params, new SecureRandom()); + fail("IllegalArgumentException must be throwm"); + } catch (IllegalArgumentException e) { + } + } + + /** + * Test for getInstance(String algorithm) method + * Assertions: + * throws NullPointerException when algorithm is null; + * throws NoSuchAlgorithmException when algorithm is incorrect; + * returns KeyAgreement object + */ + public void testGetInstance01() throws NoSuchAlgorithmException, + InvalidKeySpecException, InvalidKeyException, + ShortBufferException, InvalidAlgorithmParameterException { + try { + KeyAgreement.getInstance(null); + fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); + } catch (NullPointerException e) { + } catch (NoSuchAlgorithmException e) { + } + for (int i = 0; i < invalidValues.length; i++) { + try { + KeyAgreement.getInstance(invalidValues[i]); + fail("NoSuchAlgorithmException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (NoSuchAlgorithmException e) { + } + } + KeyAgreement keyAgr; + for (int i = 0; i < validValues.length; i++) { + keyAgr = KeyAgreement.getInstance(validValues[i]); + assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(), + validValues[i]); + assertEquals("Incorrect provider", keyAgr.getProvider(), mProv); + checkResult(keyAgr); + } + } + /** + * Test for getInstance(String algorithm, String provider) + * method + * Assertions: + * throws NullPointerException when algorithm is null; + * throws NoSuchAlgorithmException when algorithm is null or incorrect; + * throws IllegalArgumentException when provider is null or null; + * throws NoSuchProviderException when provider is available; + * returns KeyAgreement object + */ + public void testGetInstance02() throws NoSuchAlgorithmException, + NoSuchProviderException, IllegalArgumentException, + InvalidKeySpecException, InvalidKeyException, + ShortBufferException, InvalidAlgorithmParameterException { + try { + KeyAgreement.getInstance(null, mProv.getName()); + fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); + } catch (NullPointerException e) { + } catch (NoSuchAlgorithmException e) { + } + for (int i = 0; i < invalidValues.length; i++) { + try { + KeyAgreement.getInstance(invalidValues[i], mProv + .getName()); + fail("NoSuchAlgorithmException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (NoSuchAlgorithmException e) { + } + } + String prov = null; + for (int i = 0; i < validValues.length; i++) { + try { + KeyAgreement.getInstance(validValues[i], prov); + fail("IllegalArgumentException must be thrown when provider is null (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (IllegalArgumentException e) { + } + try { + KeyAgreement.getInstance(validValues[i], ""); + fail("IllegalArgumentException must be thrown when provider is empty (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (IllegalArgumentException e) { + } + for (int j = 1; j < invalidValues.length; j++) { + try { + KeyAgreement.getInstance(validValues[i], + invalidValues[j]); + fail("NoSuchProviderException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(" provider: ") + .concat(invalidValues[j]).concat(")")); + } catch (NoSuchProviderException e) { + } + } + } + KeyAgreement keyAgr; + for (int i = 0; i < validValues.length; i++) { + keyAgr = KeyAgreement.getInstance(validValues[i], mProv + .getName()); + assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(), + validValues[i]); + assertEquals("Incorrect provider", keyAgr.getProvider().getName(), + mProv.getName()); + checkResult(keyAgr); + } + } + + /** + * Test for getInstance(String algorithm, Provider provider) + * method + * Assertions: + * throws NullPointerException when algorithm is null; + * throws NoSuchAlgorithmException when algorithm is null or incorrect; + * throws IllegalArgumentException when provider is null; + * returns KeyAgreement object + * + */ + public void testGetInstance03() throws NoSuchAlgorithmException, + IllegalArgumentException, + InvalidKeySpecException, InvalidKeyException, + ShortBufferException, InvalidAlgorithmParameterException { + try { + KeyAgreement.getInstance(null, mProv); + fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); + } catch (NullPointerException e) { + } catch (NoSuchAlgorithmException e) { + } + for (int i = 0; i < invalidValues.length; i++) { + try { + KeyAgreement.getInstance(invalidValues[i], mProv); + fail("NoSuchAlgorithmException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (NoSuchAlgorithmException e) { + } + } + Provider prov = null; + for (int i = 0; i < validValues.length; i++) { + try { + KeyAgreement.getInstance(validValues[i], prov); + fail("IllegalArgumentException must be thrown when provider is null (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (IllegalArgumentException e) { + } + } + KeyAgreement keyAgr; + for (int i = 0; i < validValues.length; i++) { + keyAgr = KeyAgreement.getInstance(validValues[i], mProv); + assertEquals("Incorrect algorithm", keyAgr.getAlgorithm(), + validValues[i]); + assertEquals("Incorrect provider", keyAgr.getProvider(), mProv); + checkResult(keyAgr); + } + } +} Index: modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Mac_ImplTest.java =================================================================== --- modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Mac_ImplTest.java (revision 0) +++ modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Mac_ImplTest.java (working copy) @@ -19,7 +19,7 @@ * @version $Revision$ */ -package javax.crypto; +package org.apache.harmony.crypto.tests.javax.crypto; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; @@ -30,6 +30,7 @@ import java.security.Security; import java.security.spec.AlgorithmParameterSpec; +import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import org.apache.harmony.security.SpiEngUtils; @@ -79,15 +80,6 @@ super.tearDown(); Security.removeProvider(mProv.getName()); } - - /** - * Constructor for SecurityManagerFactoryTest2. - * - * @param arg0 - */ - public Mac_ImplTest(String arg0) { - super(arg0); - } protected void checkResult(Mac mac) throws InvalidKeyException, InvalidAlgorithmParameterException { Index: modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_Impl1Test.java =================================================================== --- modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_Impl1Test.java (revision 0) +++ modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreement_Impl1Test.java (revision 0) @@ -0,0 +1,101 @@ +/* + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* @author Vera Y. Petrashkova +* @version $Revision$ +*/ + +package org.apache.harmony.crypto.tests.javax.crypto; + +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.KeyAgreement; +import javax.crypto.KeyAgreementSpi; + +import org.apache.harmony.crypto.tests.support.MyKeyAgreementSpi; +import org.apache.harmony.security.SpiEngUtils; + +import junit.framework.TestCase; + +/** + * Tests for KeyAgreement constructor and methods + * + */ + +public class KeyAgreement_Impl1Test extends TestCase { + + public static final String srvKeyAgreement = "KeyAgreement"; + + private static String defaultAlgorithm = "DH"; + + + private static Provider defaultProvider = null; + + private static boolean DEFSupported = false; + + private static final String NotSupportMsg = "There is no suitable provider for KeyAgreement"; + + + static { + defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm, + srvKeyAgreement); + DEFSupported = (defaultProvider != null); + } + + /** + * Test for KeyAgreement constructor Assertion: returns + * KeyAgreement object + */ + public void testKeyAgreement() throws NoSuchAlgorithmException, + InvalidKeyException, IllegalStateException { + if (!DEFSupported) { + fail(NotSupportMsg); + return; + } + KeyAgreementSpi spi = new MyKeyAgreementSpi(); + KeyAgreement keyA = new myKeyAgreement(spi, defaultProvider, + defaultAlgorithm); + assertEquals("Incorrect algorithm", keyA.getAlgorithm(), + defaultAlgorithm); + assertEquals("Incorrect provider", keyA.getProvider(), defaultProvider); + assertNull("Incorrect result", keyA.doPhase(null, true)); + assertEquals("Incorrect result", keyA.generateSecret().length, 0); + + keyA = new myKeyAgreement(null, null, null); + assertNull("Algorithm must be null", keyA.getAlgorithm()); + assertNull("Provider must be null", keyA.getProvider()); + try { + keyA.doPhase(null, true); + fail("NullPointerEXception must be thrown"); + } catch (NullPointerException e) { + } + } +} + +/** + * Additional class for KeyAgreement constructor verification + */ + +class myKeyAgreement extends KeyAgreement { + + public myKeyAgreement(KeyAgreementSpi keyAgreeSpi, Provider provider, + String algorithm) { + super(keyAgreeSpi, provider, algorithm); + } +} Index: modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_ImplTest.java =================================================================== --- modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_ImplTest.java (revision 0) +++ modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_ImplTest.java (working copy) @@ -1,239 +1,233 @@ -/* - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Vera Y. Petrashkova -* @version $Revision$ -*/ - -package javax.crypto; - -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.Security; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; - -import org.apache.harmony.security.SpiEngUtils; -import junit.framework.TestCase; - - -/** - * Tests for SecretKeyFactory class constructors and methods - * - */ - -public class SecretKeyFactory_ImplTest extends TestCase { - - private static final String srvSecretKeyFactory = "SecretKeyFactory"; - private static final String defaultAlg = "MySecretKey"; - private static final String SecretKeyFactoryProviderClass = "org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi"; - - private static final String[] invalidValues = SpiEngUtils.invalidValues; - - private static final String[] validValues; - - static { - validValues = new String[4]; - validValues[0] = defaultAlg; - validValues[1] = defaultAlg.toLowerCase(); - validValues[2] = "mySECRETkey"; - validValues[3] = "MYSECretkey"; - } - - Provider mProv; - - protected void setUp() throws Exception { - super.setUp(); - mProv = (new SpiEngUtils()).new MyProvider("MySKFProvider", "Testing provider", - srvSecretKeyFactory.concat(".").concat(defaultAlg), - SecretKeyFactoryProviderClass); - Security.insertProviderAt(mProv, 2); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - Security.removeProvider(mProv.getName()); - } - - /** - * Constructor for SecurityManagerFactoryTest2. - * - * @param arg0 - */ - public SecretKeyFactory_ImplTest(String arg0) { - super(arg0); - } - - private void checkResult(SecretKeyFactory skf) throws InvalidKeyException, - InvalidKeySpecException { - SecretKey sk; - KeySpec keySpec; - sk = skf.generateSecret(null); - assertNull("generateSecret method must return null", sk); - sk = skf.translateKey(null); - assertNull("translateKey method must return null", sk); - keySpec = skf.getKeySpec(null, null); - assertNull("getKeySpec method must return null", keySpec); - } - /** - * Test for getInstance(String algorithm) method - * Assertions: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is incorrect; - * returns SecretKeyFactory object - */ - public void testGetInstance01() throws NoSuchAlgorithmException, - InvalidKeySpecException, InvalidKeyException { - try { - SecretKeyFactory.getInstance(null); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - SecretKeyFactory.getInstance(invalidValues[i]); - fail("NoSuchAlgorithmException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - SecretKeyFactory skf; - for (int i = 0; i < validValues.length; i++) { - skf = SecretKeyFactory.getInstance(validValues[i]); - assertEquals("Incorrect algorithm", skf.getAlgorithm(), - validValues[i]); - assertEquals("Incorrect provider", skf.getProvider(), mProv); - checkResult(skf); - } - } - - /** - * Test for getInstance(String algorithm, String provider) - * method - * Assertions: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is null or incorrect; - * throws IllegalArgumentException when provider is null or empty; - * throws NoSuchProviderException when provider is available; - * returns SecretKeyFactory object - */ - public void testGetInstance02() throws NoSuchAlgorithmException, - NoSuchProviderException, IllegalArgumentException, - InvalidKeySpecException, InvalidKeyException { - try { - SecretKeyFactory.getInstance(null, mProv.getName()); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - SecretKeyFactory.getInstance(invalidValues[i], mProv - .getName()); - fail("NoSuchAlgorithmException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - String prov = null; - for (int i = 0; i < validValues.length; i++) { - try { - SecretKeyFactory.getInstance(validValues[i], prov); - fail("IllegalArgumentException must be thrown when provider is null (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (IllegalArgumentException e) { - } - try { - SecretKeyFactory.getInstance(validValues[i], ""); - fail("IllegalArgumentException must be thrown when provider is empty (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (IllegalArgumentException e) { - } - for (int j = 1; j < invalidValues.length; j++) { - try { - SecretKeyFactory.getInstance(validValues[i], - invalidValues[j]); - fail("NoSuchProviderException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(" provider: ") - .concat(invalidValues[j]).concat(")")); - } catch (NoSuchProviderException e) { - } - } - } - SecretKeyFactory skf; - for (int i = 0; i < validValues.length; i++) { - skf = SecretKeyFactory.getInstance(validValues[i], mProv - .getName()); - assertEquals("Incorrect algorithm", skf.getAlgorithm(), - validValues[i]); - assertEquals("Incorrect provider", skf.getProvider().getName(), - mProv.getName()); - checkResult(skf); - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) - * method - * Assertions: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is null or incorrect; - * throws IllegalArgumentException when provider is null; - * returns SecretKeyFactory object - */ - public void testGetInstance03() throws NoSuchAlgorithmException, - IllegalArgumentException, - InvalidKeySpecException, InvalidKeyException { - try { - SecretKeyFactory.getInstance(null, mProv); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - SecretKeyFactory.getInstance(invalidValues[i], mProv); - fail("NoSuchAlgorithmException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - Provider prov = null; - for (int i = 0; i < validValues.length; i++) { - try { - SecretKeyFactory.getInstance(validValues[i], prov); - fail("IllegalArgumentException must be thrown when provider is null (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (IllegalArgumentException e) { - } - } - SecretKeyFactory skf; - for (int i = 0; i < validValues.length; i++) { - skf = SecretKeyFactory.getInstance(validValues[i], mProv); - assertEquals("Incorrect algorithm", skf.getAlgorithm(), - validValues[i]); - assertEquals("Incorrect provider", skf.getProvider(), mProv); - checkResult(skf); - } - } -} +/* + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* @author Vera Y. Petrashkova +* @version $Revision$ +*/ + +package org.apache.harmony.crypto.tests.javax.crypto; + +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Provider; +import java.security.Security; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.KeySpec; + +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; + +import org.apache.harmony.security.SpiEngUtils; +import junit.framework.TestCase; + + +/** + * Tests for SecretKeyFactory class constructors and methods + * + */ + +public class SecretKeyFactory_ImplTest extends TestCase { + + private static final String srvSecretKeyFactory = "SecretKeyFactory"; + private static final String defaultAlg = "MySecretKey"; + private static final String SecretKeyFactoryProviderClass = "org.apache.harmony.crypto.tests.support.MySecretKeyFactorySpi"; + + private static final String[] invalidValues = SpiEngUtils.invalidValues; + + private static final String[] validValues; + + static { + validValues = new String[4]; + validValues[0] = defaultAlg; + validValues[1] = defaultAlg.toLowerCase(); + validValues[2] = "mySECRETkey"; + validValues[3] = "MYSECretkey"; + } + + Provider mProv; + + protected void setUp() throws Exception { + super.setUp(); + mProv = (new SpiEngUtils()).new MyProvider("MySKFProvider", "Testing provider", + srvSecretKeyFactory.concat(".").concat(defaultAlg), + SecretKeyFactoryProviderClass); + Security.insertProviderAt(mProv, 2); + } + + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + Security.removeProvider(mProv.getName()); + } + + private void checkResult(SecretKeyFactory skf) throws InvalidKeyException, + InvalidKeySpecException { + SecretKey sk; + KeySpec keySpec; + sk = skf.generateSecret(null); + assertNull("generateSecret method must return null", sk); + sk = skf.translateKey(null); + assertNull("translateKey method must return null", sk); + keySpec = skf.getKeySpec(null, null); + assertNull("getKeySpec method must return null", keySpec); + } + /** + * Test for getInstance(String algorithm) method + * Assertions: + * throws NullPointerException when algorithm is null; + * throws NoSuchAlgorithmException when algorithm is incorrect; + * returns SecretKeyFactory object + */ + public void testGetInstance01() throws NoSuchAlgorithmException, + InvalidKeySpecException, InvalidKeyException { + try { + SecretKeyFactory.getInstance(null); + fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); + } catch (NullPointerException e) { + } catch (NoSuchAlgorithmException e) { + } + for (int i = 0; i < invalidValues.length; i++) { + try { + SecretKeyFactory.getInstance(invalidValues[i]); + fail("NoSuchAlgorithmException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (NoSuchAlgorithmException e) { + } + } + SecretKeyFactory skf; + for (int i = 0; i < validValues.length; i++) { + skf = SecretKeyFactory.getInstance(validValues[i]); + assertEquals("Incorrect algorithm", skf.getAlgorithm(), + validValues[i]); + assertEquals("Incorrect provider", skf.getProvider(), mProv); + checkResult(skf); + } + } + + /** + * Test for getInstance(String algorithm, String provider) + * method + * Assertions: + * throws NullPointerException when algorithm is null; + * throws NoSuchAlgorithmException when algorithm is null or incorrect; + * throws IllegalArgumentException when provider is null or empty; + * throws NoSuchProviderException when provider is available; + * returns SecretKeyFactory object + */ + public void testGetInstance02() throws NoSuchAlgorithmException, + NoSuchProviderException, IllegalArgumentException, + InvalidKeySpecException, InvalidKeyException { + try { + SecretKeyFactory.getInstance(null, mProv.getName()); + fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); + } catch (NullPointerException e) { + } catch (NoSuchAlgorithmException e) { + } + for (int i = 0; i < invalidValues.length; i++) { + try { + SecretKeyFactory.getInstance(invalidValues[i], mProv + .getName()); + fail("NoSuchAlgorithmException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (NoSuchAlgorithmException e) { + } + } + String prov = null; + for (int i = 0; i < validValues.length; i++) { + try { + SecretKeyFactory.getInstance(validValues[i], prov); + fail("IllegalArgumentException must be thrown when provider is null (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (IllegalArgumentException e) { + } + try { + SecretKeyFactory.getInstance(validValues[i], ""); + fail("IllegalArgumentException must be thrown when provider is empty (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (IllegalArgumentException e) { + } + for (int j = 1; j < invalidValues.length; j++) { + try { + SecretKeyFactory.getInstance(validValues[i], + invalidValues[j]); + fail("NoSuchProviderException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(" provider: ") + .concat(invalidValues[j]).concat(")")); + } catch (NoSuchProviderException e) { + } + } + } + SecretKeyFactory skf; + for (int i = 0; i < validValues.length; i++) { + skf = SecretKeyFactory.getInstance(validValues[i], mProv + .getName()); + assertEquals("Incorrect algorithm", skf.getAlgorithm(), + validValues[i]); + assertEquals("Incorrect provider", skf.getProvider().getName(), + mProv.getName()); + checkResult(skf); + } + } + + /** + * Test for getInstance(String algorithm, Provider provider) + * method + * Assertions: + * throws NullPointerException when algorithm is null; + * throws NoSuchAlgorithmException when algorithm is null or incorrect; + * throws IllegalArgumentException when provider is null; + * returns SecretKeyFactory object + */ + public void testGetInstance03() throws NoSuchAlgorithmException, + IllegalArgumentException, + InvalidKeySpecException, InvalidKeyException { + try { + SecretKeyFactory.getInstance(null, mProv); + fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); + } catch (NullPointerException e) { + } catch (NoSuchAlgorithmException e) { + } + for (int i = 0; i < invalidValues.length; i++) { + try { + SecretKeyFactory.getInstance(invalidValues[i], mProv); + fail("NoSuchAlgorithmException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (NoSuchAlgorithmException e) { + } + } + Provider prov = null; + for (int i = 0; i < validValues.length; i++) { + try { + SecretKeyFactory.getInstance(validValues[i], prov); + fail("IllegalArgumentException must be thrown when provider is null (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (IllegalArgumentException e) { + } + } + SecretKeyFactory skf; + for (int i = 0; i < validValues.length; i++) { + skf = SecretKeyFactory.getInstance(validValues[i], mProv); + assertEquals("Incorrect algorithm", skf.getAlgorithm(), + validValues[i]); + assertEquals("Incorrect provider", skf.getProvider(), mProv); + checkResult(skf); + } + } +} Index: modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_Impl1Test.java =================================================================== --- modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_Impl1Test.java (revision 0) +++ modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactory_Impl1Test.java (revision 0) @@ -0,0 +1,120 @@ +/* + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* @author Vera Y. Petrashkova +* @version $Revision$ +*/ + +package org.apache.harmony.crypto.tests.javax.crypto; + +import java.security.InvalidKeyException; +import java.security.Provider; + +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.SecretKeySpec; + +import org.apache.harmony.security.SpiEngUtils; +import junit.framework.TestCase; +/** + * Tests for SecretKeyFactory class constructors and methods. + * + */ + +public class SecretKeyFactory_Impl1Test extends TestCase { + + public static final String srvSecretKeyFactory = "SecretKeyFactory"; + + private static String defaultAlgorithm1 = "DESede"; + private static String defaultAlgorithm2 = "DES"; + + public static String defaultAlgorithm = null; + + private static String defaultProviderName = null; + + private static Provider defaultProvider = null; + + private static boolean DEFSupported = false; + + private static final String NotSupportMsg = "Default algorithm is not supported"; + + static { + defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm1, + srvSecretKeyFactory); + DEFSupported = (defaultProvider != null); + if (DEFSupported) { + defaultAlgorithm = defaultAlgorithm1; + defaultProviderName = defaultProvider.getName(); + } else { + defaultProvider = SpiEngUtils.isSupport(defaultAlgorithm2, + srvSecretKeyFactory); + DEFSupported = (defaultProvider != null); + if (DEFSupported) { + defaultAlgorithm = defaultAlgorithm2; + defaultProviderName = defaultProvider.getName(); + } else { + defaultAlgorithm = null; + defaultProviderName = null; + defaultProvider = null; + } + } + } + + protected SecretKeyFactory[] createSKFac() { + if (!DEFSupported) { + fail(defaultAlgorithm + " algorithm is not supported"); + return null; + } + SecretKeyFactory[] skF = new SecretKeyFactory[3]; + try { + skF[0] = SecretKeyFactory.getInstance(defaultAlgorithm); + skF[1] = SecretKeyFactory.getInstance(defaultAlgorithm, + defaultProvider); + skF[2] = SecretKeyFactory.getInstance(defaultAlgorithm, + defaultProviderName); + return skF; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * Test for translateKey(SecretKey key) method + * Assertion: + * throw InvalidKeyException if parameter is inappropriate + */ + public void testSecretKeyFactory11() throws InvalidKeyException { + if (!DEFSupported) { + fail(NotSupportMsg); + return; + } + byte[] bb = new byte[10]; + SecretKeySpec secKeySpec = new SecretKeySpec(bb,defaultAlgorithm); + SecretKeyFactory[] skF = createSKFac(); + assertNotNull("SecretKeyFactory object were not created", skF); + for (int i = 0; i < skF.length; i++) { + try { + skF[i].translateKey(null); + fail("InvalidKeyException must be thrown: " + i); + } catch (InvalidKeyException e) { + } + + skF[i].translateKey(secKeySpec); + } + } +} + Index: modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_ImplTest.java =================================================================== --- modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_ImplTest.java (revision 0) +++ modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_ImplTest.java (working copy) @@ -1,477 +1,300 @@ -/* - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** -* @author Boris V. Kuznetsov -* @version $Revision$ -*/ - -package javax.crypto; - -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.Provider; -import java.security.Security; -import java.security.spec.InvalidKeySpecException; - -import org.apache.harmony.security.support.TestKeyPair; - - -import junit.framework.TestCase; - -/** - * Tests for Cipher class constructors and methods. - * - */ -public class Cipher_ImplTest extends TestCase { - - private Provider p1; - private Provider p2; - private TestKeyPair tkp = null; - private Key key = null; - - private boolean noKey = false; - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - p1 = new MyProvider1(); - p2 = new MyProvider2(); - Security.insertProviderAt(p1, 1); - Security.insertProviderAt(p2, 1); - try { - tkp = new TestKeyPair("DSA"); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - noKey = true; - return; - } - - try { - key = tkp.getPrivate(); - } catch (InvalidKeySpecException e) { - e.printStackTrace(); - noKey = true; - return; - } - - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - Security.removeProvider("MyProvider1"); - Security.removeProvider("MyProvider2"); - } - - /* - * Class under test for Cipher getInstance(String) - */ - public void testGetInstanceString1() throws NoSuchAlgorithmException, - NoSuchPaddingException { - - Cipher c = Cipher.getInstance("DES"); - assertSame(p2, c.getProvider()); - } - - /* - * Class under test for Cipher getInstance(String) - */ - public void testGetInstanceString2() throws NoSuchAlgorithmException, - NoSuchPaddingException { - - Cipher c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - assertSame("Case1:", p1, c.getProvider()); - - Security.removeProvider(p1.getName()); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding"); - assertSame("Case2:", p2, c.getProvider()); - } - - /* - * Class under test for Cipher getInstance(String) - */ - public void testGetInstanceString3() throws NoSuchAlgorithmException, - NoSuchPaddingException { - - try { - Cipher.getInstance("DES/CBC/"); - fail("Case1: No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - - try { - Cipher.getInstance("DES//PKCS5Padding"); - fail("Case2: No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - - try { - Cipher.getInstance("DES/CBC/IncorrectPadding"); - fail("No expected NoSuchPaddingException"); - } catch (NoSuchPaddingException e) { - } - } - - - /* - * Class under test for Cipher getInstance(String, String) - */ - public void testGetInstanceStringString1() throws NoSuchAlgorithmException, - NoSuchProviderException, NoSuchPaddingException { - - try { - Cipher.getInstance("DES/CBC/", "MyProvider2"); - fail("Case1: No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - - try { - Cipher.getInstance("DES//PKCS5Padding", "MyProvider2"); - fail("Case2: No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - - try { - Cipher.getInstance("DES/CBC/IncorrectPadding", "MyProvider2"); - fail("No expected NoSuchPaddingException"); - } catch (NoSuchPaddingException e) { - } - - try { - Cipher.getInstance("DES/CBC/PKCS5Padding", "IncorrectProvider"); - fail("No expected NoSuchProviderException"); - } catch (NoSuchProviderException e) { - } - } - - /* - * Class under test for Cipher getInstance(String, String) - */ - public void testGetInstanceStringString2() throws NoSuchAlgorithmException, - NoSuchProviderException, NoSuchPaddingException { - - Cipher c = Cipher.getInstance("DES", "MyProvider2"); - assertSame("Case1:", p2, c.getProvider()); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding", "MyProvider2"); - assertSame("Case2:", p2, c.getProvider()); - } - /* - * Class under test for Cipher getInstance(String, Provider) - */ - public void testGetInstanceStringProvider1() - throws NoSuchAlgorithmException, NoSuchPaddingException { - - try { - Cipher.getInstance("DES/CBC/", p2); - fail("Case1: No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - - try { - Cipher.getInstance("DES//PKCS5Padding", p2); - fail("Case2: No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - - try { - Cipher.getInstance("DES/CBC/IncorrectPadding", p2); - fail("No expected NoSuchProviderException"); - } catch (NoSuchPaddingException e) { - } - - try { - Cipher.getInstance("DES/CBC/PKCS5Padding", "IncorrectProvider"); - fail("No expected NoSuchProviderException"); - } catch (NoSuchProviderException e) { - } - } - - /* - * Class under test for Cipher getInstance(String, Provider) - */ - public void testGetInstanceStringProvider2() - throws NoSuchAlgorithmException, NoSuchPaddingException { - - Cipher c = Cipher.getInstance("DES", p2); - assertSame("Case1:", p2, c.getProvider()); - - c = Cipher.getInstance("DES/CBC/PKCS5Padding", p2); - assertSame("Case2:", p2, c.getProvider()); - assertFalse("getAlgorithm", "DES".equals(c.getAlgorithm())); - } - - public void testGetBlockSize() throws NoSuchAlgorithmException, - NoSuchPaddingException { - - Cipher c = Cipher.getInstance("DES"); - assertEquals("getBlockSize", 111, c.getBlockSize()); - } - - public void testGetOutputSize() throws NoSuchAlgorithmException, - NoSuchPaddingException, InvalidKeyException { - - Cipher c = Cipher.getInstance("DES"); - try { - c.getOutputSize(111); - fail("No expected IllegalStateException"); - } catch (IllegalStateException e){ - } - - if (noKey) { - return; - } - - c.init(Cipher.DECRYPT_MODE, key); - assertEquals("getOutputSize", 121, c.getOutputSize(111)); - } - - public void testGetIV() throws NoSuchAlgorithmException, - NoSuchPaddingException { - - Cipher c = Cipher.getInstance("DES"); - assertEquals(3, c.getIV().length); - } - - public void testGetParameters() throws NoSuchAlgorithmException, - NoSuchPaddingException { - - Cipher c = Cipher.getInstance("DES"); - assertNull(c.getParameters()); - } - - public void testGetExemptionMechanism() { -//FIXME implement testGetExemptionMechanism - } - - /* - * Class under test for void init(int, Key) - */ - public void testInitintKey() { - } - - /* - * Class under test for void init(int, Key, SecureRandom) - */ - public void testInitintKeySecureRandom() { - } - - /* - * Class under test for void init(int, Key, AlgorithmParameterSpec) - */ - public void testInitintKeyAlgorithmParameterSpec() { - } - - /* - * Class under test for void init(int, Key, AlgorithmParameterSpec, SecureRandom) - */ - public void testInitintKeyAlgorithmParameterSpecSecureRandom() { - } - - /* - * Class under test for void init(int, Key, AlgorithmParameters) - */ - public void testInitintKeyAlgorithmParameters() { - } - - /* - * Class under test for void init(int, Key, AlgorithmParameters, SecureRandom) - */ - public void testInitintKeyAlgorithmParametersSecureRandom() { - } - - /* - * Class under test for void init(int, Certificate) - */ - public void testInitintCertificate() { - } - - /* - * Class under test for void init(int, Certificate, SecureRandom) - */ - public void testInitintCertificateSecureRandom() { - } - - /* - * Class under test for byte[] update(byte[]) - */ - public void testUpdatebyteArray() throws NoSuchAlgorithmException, - NoSuchPaddingException, InvalidKeyException { - - Cipher c = Cipher.getInstance("DES"); - - byte[] b = {1,2,3,4}; - try { - c.update(b); - fail("No expected IllegalStateException"); - } catch (IllegalStateException e){ - } - if (noKey) { - return; - } - - c.init(Cipher.DECRYPT_MODE, key); - try { - c.update(null); - fail("No expected IllegalArgumentException"); - } catch (IllegalArgumentException e){ - } - assertNull(c.update(new byte[0])); - } - - /* - * Class under test for byte[] update(byte[], int, int) - */ - public void testUpdatebyteArrayintint() { - } - - /* - * Class under test for int update(byte[], int, int, byte[]) - */ - public void testUpdatebyteArrayintintbyteArray() { - } - - /* - * Class under test for int update(byte[], int, int, byte[], int) - */ - public void testUpdatebyteArrayintintbyteArrayint() { -// try { -// spi.engineUpdate(b, 3, 6, b1, 5); -// fail("No expected ShortBufferException"); -// } catch (ShortBufferException e) { -// } - } - - /* - * Class under test for int update(ByteBuffer, ByteBuffer) - */ - public void testUpdateByteBufferByteBuffer() { - } - - /* - * Class under test for byte[] doFinal() - */ - public void testDoFinal() { - } - - /* - * Class under test for int doFinal(byte[], int) - */ - public void testDoFinalbyteArrayint() { - } - - /* - * Class under test for byte[] doFinal(byte[]) - */ - public void testDoFinalbyteArray() { - } - - /* - * Class under test for byte[] doFinal(byte[], int, int) - */ - public void testDoFinalbyteArrayintint() { - } - - /* - * Class under test for int doFinal(byte[], int, int, byte[]) - */ - public void testDoFinalbyteArrayintintbyteArray() { - } - - /* - * Class under test for int doFinal(byte[], int, int, byte[], int) - */ - public void testDoFinalbyteArrayintintbyteArrayint() { -// try { -// spi.engineDoFinal(b, 3, 6, b1, 5); -// fail("No expected ShortBufferException"); -// } catch (ShortBufferException e) { -// } catch (Exception e) { -// fail(e.toString()); -// } - } - - /* - * Class under test for int doFinal(ByteBuffer, ByteBuffer) - */ - public void testDoFinalByteBufferByteBuffer() { - } - - public void testWrap() { - } - - public void testUnwrap() { - } - - public void testGetMaxAllowedKeyLength() throws NoSuchAlgorithmException { - try { - Cipher.getMaxAllowedKeyLength(null); - fail("No expected NullPointerException"); - } catch (NullPointerException e) { - } - try { - Cipher.getMaxAllowedKeyLength("//CBC/PKCS5Paddin"); - fail("No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - try { - Cipher.getMaxAllowedKeyLength("/DES/CBC/PKCS5Paddin/1"); - fail("No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - } - - public void testGetMaxAllowedParameterSpec() - throws NoSuchAlgorithmException { - try { - Cipher.getMaxAllowedParameterSpec(null); - fail("No expected NullPointerException"); - } catch (NullPointerException e) { - } - try { - Cipher.getMaxAllowedParameterSpec("/DES//PKCS5Paddin"); - fail("No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - try { - Cipher.getMaxAllowedParameterSpec("/DES/CBC/ /1"); - fail("No expected NoSuchAlgorithmException"); - } catch (NoSuchAlgorithmException e) { - } - } - - private class MyProvider1 extends Provider { - MyProvider1() { - super("MyProvider1", 1.0, "Provider1 for testing"); - put("Cipher.DES/CBC/PKCS5Padding", "org.apache.harmony.crypto.tests.support.MyCipher"); - put("Cipher.DES/ECB/PKCS5Padding", "org.apache.harmony.crypto.tests.support.MyCipher"); - } - } - private class MyProvider2 extends Provider { - MyProvider2() { - super("MyProvider2", 1.0, "Provider2 for testing"); - put("Cipher.DES", "org.apache.harmony.crypto.tests.support.MyCipher"); - } - - } +/* + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** +* @author Boris V. Kuznetsov +* @version $Revision$ +*/ + +package org.apache.harmony.crypto.tests.javax.crypto; + +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Provider; +import java.security.Security; +import java.security.spec.InvalidKeySpecException; + +import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.ShortBufferException; + +import org.apache.harmony.security.support.TestKeyPair; + +import junit.framework.TestCase; + +/** + * Tests for Cipher class constructors and methods. + * + */ +public class Cipher_ImplTest extends TestCase { + + private Provider p1; + private Provider p2; + private TestKeyPair tkp = null; + private Key key = null; + + private boolean noKey = false; + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + p1 = new MyProvider1(); + p2 = new MyProvider2(); + Security.insertProviderAt(p1, 1); + Security.insertProviderAt(p2, 1); + try { + tkp = new TestKeyPair("DSA"); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + noKey = true; + return; + } + + try { + key = tkp.getPrivate(); + } catch (InvalidKeySpecException e) { + e.printStackTrace(); + noKey = true; + return; + } + + } + + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + Security.removeProvider("MyProvider1"); + Security.removeProvider("MyProvider2"); + } + + /* + * Class under test for Cipher getInstance(String) + */ + public void testGetInstanceString1() throws NoSuchAlgorithmException, + NoSuchPaddingException { + + Cipher c = Cipher.getInstance("DES"); + assertSame(p2, c.getProvider()); + } + + /* + * Class under test for Cipher getInstance(String) + */ + public void testGetInstanceString2() throws NoSuchAlgorithmException, + NoSuchPaddingException { + + Cipher c = Cipher.getInstance("DES/CBC/PKCS5Padding"); + assertSame("Case1:", p1, c.getProvider()); + + Security.removeProvider(p1.getName()); + + c = Cipher.getInstance("DES/CBC/PKCS5Padding"); + assertSame("Case2:", p2, c.getProvider()); + } + + /* + * Class under test for Cipher getInstance(String) + */ + public void testGetInstanceString3() throws NoSuchAlgorithmException, + NoSuchPaddingException { + + try { + Cipher.getInstance("DES/CBC/"); + fail("Case1: No expected NoSuchAlgorithmException"); + } catch (NoSuchAlgorithmException e) { + } + + try { + Cipher.getInstance("DES//PKCS5Padding"); + fail("Case2: No expected NoSuchAlgorithmException"); + } catch (NoSuchAlgorithmException e) { + } + + try { + Cipher.getInstance("DES/CBC/IncorrectPadding"); + fail("No expected NoSuchPaddingException"); + } catch (NoSuchPaddingException e) { + } + } + + + /* + * Class under test for Cipher getInstance(String, String) + */ + public void testGetInstanceStringString1() throws NoSuchAlgorithmException, + NoSuchProviderException, NoSuchPaddingException { + + try { + Cipher.getInstance("DES/CBC/", "MyProvider2"); + fail("Case1: No expected NoSuchAlgorithmException"); + } catch (NoSuchAlgorithmException e) { + } + + try { + Cipher.getInstance("DES//PKCS5Padding", "MyProvider2"); + fail("Case2: No expected NoSuchAlgorithmException"); + } catch (NoSuchAlgorithmException e) { + } + + try { + Cipher.getInstance("DES/CBC/IncorrectPadding", "MyProvider2"); + fail("No expected NoSuchPaddingException"); + } catch (NoSuchPaddingException e) { + } + + try { + Cipher.getInstance("DES/CBC/PKCS5Padding", "IncorrectProvider"); + fail("No expected NoSuchProviderException"); + } catch (NoSuchProviderException e) { + } + } + + /* + * Class under test for Cipher getInstance(String, String) + */ + public void testGetInstanceStringString2() throws NoSuchAlgorithmException, + NoSuchProviderException, NoSuchPaddingException { + + Cipher c = Cipher.getInstance("DES", "MyProvider2"); + assertSame("Case1:", p2, c.getProvider()); + + c = Cipher.getInstance("DES/CBC/PKCS5Padding", "MyProvider2"); + assertSame("Case2:", p2, c.getProvider()); + } + /* + * Class under test for Cipher getInstance(String, Provider) + */ + public void testGetInstanceStringProvider1() + throws NoSuchAlgorithmException, NoSuchPaddingException { + + try { + Cipher.getInstance("DES/CBC/", p2); + fail("Case1: No expected NoSuchAlgorithmException"); + } catch (NoSuchAlgorithmException e) { + } + + try { + Cipher.getInstance("DES//PKCS5Padding", p2); + fail("Case2: No expected NoSuchAlgorithmException"); + } catch (NoSuchAlgorithmException e) { + } + + try { + Cipher.getInstance("DES/CBC/IncorrectPadding", p2); + fail("No expected NoSuchProviderException"); + } catch (NoSuchPaddingException e) { + } + + try { + Cipher.getInstance("DES/CBC/PKCS5Padding", "IncorrectProvider"); + fail("No expected NoSuchProviderException"); + } catch (NoSuchProviderException e) { + } + } + + /* + * Class under test for Cipher getInstance(String, Provider) + */ + public void testGetInstanceStringProvider2() + throws NoSuchAlgorithmException, NoSuchPaddingException { + + Cipher c = Cipher.getInstance("DES", p2); + assertSame("Case1:", p2, c.getProvider()); + + c = Cipher.getInstance("DES/CBC/PKCS5Padding", p2); + assertSame("Case2:", p2, c.getProvider()); + assertFalse("getAlgorithm", "DES".equals(c.getAlgorithm())); + } + + public void testGetBlockSize() throws NoSuchAlgorithmException, + NoSuchPaddingException { + + Cipher c = Cipher.getInstance("DES"); + assertEquals("getBlockSize", 111, c.getBlockSize()); + } + + public void testGetOutputSize() throws NoSuchAlgorithmException, + NoSuchPaddingException, InvalidKeyException { + + Cipher c = Cipher.getInstance("DES"); + try { + c.getOutputSize(111); + fail("No expected IllegalStateException"); + } catch (IllegalStateException e){ + } + + if (noKey) { + return; + } + + c.init(Cipher.DECRYPT_MODE, key); + assertEquals("getOutputSize", 121, c.getOutputSize(111)); + } + + public void testGetIV() throws NoSuchAlgorithmException, + NoSuchPaddingException { + + Cipher c = Cipher.getInstance("DES"); + assertEquals(3, c.getIV().length); + } + + /* + * Class under test for byte[] update(byte[]) + */ + public void testUpdatebyteArray() throws NoSuchAlgorithmException, + NoSuchPaddingException, InvalidKeyException { + + Cipher c = Cipher.getInstance("DES"); + + byte[] b = {1,2,3,4}; + try { + c.update(b); + fail("No expected IllegalStateException"); + } catch (IllegalStateException e){ + } + if (noKey) { + return; + } + + c.init(Cipher.DECRYPT_MODE, key); + try { + c.update(null); + fail("No expected IllegalArgumentException"); + } catch (IllegalArgumentException e){ + } + assertNull(c.update(new byte[0])); + } + + private class MyProvider1 extends Provider { + MyProvider1() { + super("MyProvider1", 1.0, "Provider1 for testing"); + put("Cipher.DES/CBC/PKCS5Padding", "org.apache.harmony.crypto.tests.support.MyCipher"); + put("Cipher.DES/ECB/PKCS5Padding", "org.apache.harmony.crypto.tests.support.MyCipher"); + } + } + private class MyProvider2 extends Provider { + MyProvider2() { + super("MyProvider2", 1.0, "Provider2 for testing"); + put("Cipher.DES", "org.apache.harmony.crypto.tests.support.MyCipher"); + } + + } } \ No newline at end of file Index: modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_Impl1Test.java =================================================================== --- modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_Impl1Test.java (revision 0) +++ modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/Cipher_Impl1Test.java (revision 0) @@ -0,0 +1,101 @@ +/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.crypto.tests.javax.crypto; + +import java.security.AlgorithmParameters; +import java.security.Key; +import java.security.SecureRandom; +import java.util.Arrays; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; + +public class Cipher_Impl1Test extends junit.framework.TestCase { + + static Key cipherKey; + final static String algorithm = "DESede"; + final static int keyLen = 168; + + static { + try { + KeyGenerator kg = KeyGenerator.getInstance(algorithm); + kg.init(keyLen, new SecureRandom()); + cipherKey = kg.generateKey(); + } catch (Exception e) { + fail("No key " + e); + } + } + + + /** + * @tests javax.crypto.Cipher#getIV() + * @tests javax.crypto.Cipher#init(int, java.security.Key, + * java.security.AlgorithmParameters) + */ + public void test_getIV() throws Exception { + /* + * If this test is changed, implement the following: + * test_initILjava_security_KeyLjava_security_AlgorithmParameters() + */ + + SecureRandom sr = new SecureRandom(); + Cipher cipher = null; + + byte[] iv = new byte[8]; + sr.nextBytes(iv); + AlgorithmParameters ap = AlgorithmParameters.getInstance(algorithm); + ap.init(iv, "RAW"); + + cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap); + + byte[] cipherIV = cipher.getIV(); + + assertTrue("IVs differ", Arrays.equals(cipherIV, iv)); + } + + /** + * @tests javax.crypto.Cipher#getParameters() + * @tests javax.crypto.Cipher#init(int, java.security.Key, + * java.security.AlgorithmParameters, java.security.SecureRandom) + */ + public void test_getParameters() throws Exception { + + /* + * If this test is changed, implement the following: + * test_initILjava_security_KeyLjava_security_AlgorithmParametersLjava_security_SecureRandom() + */ + + SecureRandom sr = new SecureRandom(); + Cipher cipher = null; + + byte[] apEncoding = null; + + byte[] iv = new byte[8]; + sr.nextBytes(iv); + + AlgorithmParameters ap = AlgorithmParameters.getInstance("DESede"); + ap.init(iv, "RAW"); + apEncoding = ap.getEncoded("ASN.1"); + + cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap, sr); + + byte[] cipherParmsEnc = cipher.getParameters().getEncoded("ASN.1"); + assertTrue("Parameters differ", Arrays.equals(apEncoding, + cipherParmsEnc)); + } +} Index: modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanism_ImplTest.java =================================================================== --- modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanism_ImplTest.java (revision 0) +++ modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanism_ImplTest.java (revision 0) @@ -0,0 +1,318 @@ +/* + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* @author Vera Y. Petrashkova +* @version $Revision$ +*/ + +package org.apache.harmony.crypto.tests.javax.crypto; + +import java.security.AlgorithmParameters; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Provider; +import java.security.Security; +import java.security.spec.AlgorithmParameterSpec; + +import javax.crypto.ExemptionMechanism; +import javax.crypto.ExemptionMechanismException; +import javax.crypto.ExemptionMechanismSpi; +import javax.crypto.ShortBufferException; +import javax.crypto.spec.SecretKeySpec; + +import org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi; +import org.apache.harmony.security.SpiEngUtils; +import junit.framework.TestCase; + + +/** + * Tests for ExemptionMechanism class constructors and methods + * + */ + +public class ExemptionMechanism_ImplTest extends TestCase { + + public static final String srvExemptionMechanism = "ExemptionMechanism"; + + private static final String defaultAlg = "EMech"; + + private static final String ExemptionMechanismProviderClass = "org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi"; + + private static final String[] invalidValues = SpiEngUtils.invalidValues; + + private static final String[] validValues; + + static { + validValues = new String[4]; + validValues[0] = defaultAlg; + validValues[1] = defaultAlg.toLowerCase(); + validValues[2] = "eMEch"; + validValues[3] = "emecH"; + } + + Provider mProv; + + protected void setUp() throws Exception { + super.setUp(); + mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", "Provider for ExemptionMechanism testing", + srvExemptionMechanism.concat(".").concat(defaultAlg), + ExemptionMechanismProviderClass); + Security.insertProviderAt(mProv, 1); + } + + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + Security.removeProvider(mProv.getName()); + } + + private void checkResult(ExemptionMechanism exMech) + throws ExemptionMechanismException, ShortBufferException, + InvalidKeyException, InvalidAlgorithmParameterException { + Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); + byte [] emptyA = new byte[0]; + int len = MyExemptionMechanismSpi.getLength(); + byte [] byteA = new byte[len]; + try { + exMech.genExemptionBlob(); + fail("IllegalStateException must be thrown"); + } catch (IllegalStateException e) { + } + try { + exMech.genExemptionBlob(byteA); + fail("IllegalStateException must be thrown"); + } catch (IllegalStateException e) { + } + try { + exMech.genExemptionBlob(byteA, 1); + fail("IllegalStateException must be thrown"); + } catch (IllegalStateException e) { + } + try { + exMech.getOutputSize(0); + fail("IllegalStateException must be thrown"); + } catch (IllegalStateException e) { + } + + exMech.init(key); + byte [] bbRes = exMech.genExemptionBlob(); + assertEquals("Incorrect length", bbRes.length, len); + assertEquals("Incorrect result", exMech.genExemptionBlob(new byte[5]), 5); + assertEquals("Incorrect result", exMech.genExemptionBlob(bbRes), len); + try { + exMech.genExemptionBlob(new byte[1], len); + fail("ShortBufferException must be thrown"); + } catch (ShortBufferException e) { + } + try { + exMech.genExemptionBlob(emptyA); + fail("ShortBufferException must be thrown"); + } catch (ShortBufferException e) { + } + + assertEquals("Incorrect result", exMech.genExemptionBlob(byteA, 1), 9); + assertEquals("Incorrect result", exMech.genExemptionBlob(new byte[20], (len - 2)), len); + + assertEquals("Incorrect output size", exMech.getOutputSize(100), 5); + + AlgorithmParameters params = null; + exMech.init(key, params); + AlgorithmParameterSpec parSpec = null; + exMech.init(key, parSpec); + key = new SecretKeySpec(new byte[10], "DSA"); + try { + exMech.init(key); + fail("ExemptionMechanismException must be throwm"); + } catch (ExemptionMechanismException e) { + assertTrue("Empty message", (e.getMessage().length() > 0)); + } + try { + exMech.init(key, params); + fail("ExemptionMechanismException must be throwm"); + } catch (ExemptionMechanismException e) { + assertTrue("Empty message", (e.getMessage().length() > 0)); + } + try { + exMech.init(key, parSpec); + fail("ExemptionMechanismException must be throwm"); + } catch (ExemptionMechanismException e) { + assertTrue("Empty message", (e.getMessage().length() > 0)); + } + } + + /** + * Test for getInstance(String algorithm) method + * Assertions: + * throws NullPointerException when algorithm is null; + * throws NoSuchAlgorithmException when algorithm is incorrect; + * returns ExemptionMechanism object + */ + public void testGetInstance01() throws NoSuchAlgorithmException, + ExemptionMechanismException, InvalidAlgorithmParameterException, + ShortBufferException, InvalidKeyException { + try { + ExemptionMechanism.getInstance(null); + fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); + } catch (NullPointerException e) { + } catch (NoSuchAlgorithmException e) { + } + for (int i = 0; i < invalidValues.length; i++) { + try { + ExemptionMechanism.getInstance(invalidValues[i]); + fail("NoSuchAlgorithmException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (NoSuchAlgorithmException e) { + } + } + ExemptionMechanism exMech; + for (int i = 0; i < validValues.length; i++) { + exMech = ExemptionMechanism.getInstance(validValues[i]); + assertEquals("Incorrect algorithm", exMech.getName(), + validValues[i]); + assertEquals("Incorrect provider", exMech.getProvider(), mProv); + checkResult(exMech); + } + } + + /** + * Test for getInstance(String algorithm, String provider) + * method + * Assertions: + * throws NullPointerException when algorithm is null; + * throws NoSuchAlgorithmException when algorithm is null or incorrect; + * throws IllegalArgumentException when provider is null; + * throws NoSuchProviderException when provider is available; + * returns ExemptionMechanism object + */ + public void testGetInstance02() throws NoSuchAlgorithmException, + NoSuchProviderException, IllegalArgumentException, + ExemptionMechanismException, InvalidAlgorithmParameterException, + ShortBufferException, InvalidKeyException { + try { + ExemptionMechanism.getInstance(null, mProv.getName()); + fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); + } catch (NullPointerException e) { + } catch (NoSuchAlgorithmException e) { + } + for (int i = 0; i < invalidValues.length; i++) { + try { + ExemptionMechanism.getInstance(invalidValues[i], mProv + .getName()); + fail("NoSuchAlgorithmException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (NoSuchAlgorithmException e) { + } + } + String prov = null; + for (int i = 0; i < validValues.length; i++) { + try { + ExemptionMechanism.getInstance(validValues[i], prov); + fail("IllegalArgumentException must be thrown when provider is null (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (IllegalArgumentException e) { + } + } + for (int i = 0; i < validValues.length; i++) { + for (int j = 1; j < invalidValues.length; j++) { + try { + ExemptionMechanism.getInstance(validValues[i], + invalidValues[j]); + fail("NoSuchProviderException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(" provider: ") + .concat(invalidValues[j]).concat(")")); + } catch (NoSuchProviderException e) { + } + } + } + ExemptionMechanism exMech; + for (int i = 0; i < validValues.length; i++) { + exMech = ExemptionMechanism.getInstance(validValues[i], mProv + .getName()); + assertEquals("Incorrect algorithm", exMech.getName(), + validValues[i]); + assertEquals("Incorrect provider", exMech.getProvider().getName(), + mProv.getName()); + checkResult(exMech); + } + } + + /** + * Test for getInstance(String algorithm, Provider provider) + * method + * Assertions: + * throws NullPointerException when algorithm is null; + * throws NoSuchAlgorithmException when algorithm is null or incorrect; + * throws IllegalArgumentException when provider is null; + * returns ExemptionMechanism object + */ + public void testGetInstance03() throws NoSuchAlgorithmException, + IllegalArgumentException, + ExemptionMechanismException, InvalidAlgorithmParameterException, + ShortBufferException, InvalidKeyException { + try { + ExemptionMechanism.getInstance(null, mProv); + fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); + } catch (NullPointerException e) { + } catch (NoSuchAlgorithmException e) { + } + for (int i = 0; i < invalidValues.length; i++) { + try { + ExemptionMechanism.getInstance(invalidValues[i], mProv); + fail("NoSuchAlgorithmException must be thrown (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (NoSuchAlgorithmException e) { + } + } + Provider prov = null; + for (int i = 0; i < validValues.length; i++) { + try { + ExemptionMechanism.getInstance(validValues[i], prov); + fail("IllegalArgumentException must be thrown when provider is null (algorithm: " + .concat(invalidValues[i]).concat(")")); + } catch (IllegalArgumentException e) { + } + } + ExemptionMechanism exMech; + for (int i = 0; i < validValues.length; i++) { + exMech = ExemptionMechanism.getInstance(validValues[i], mProv); + assertEquals("Incorrect algorithm", exMech.getName(), + validValues[i]); + assertEquals("Incorrect provider", exMech.getProvider(), mProv); + checkResult(exMech); + } + } +} + +class myEM extends ExemptionMechanism { + + public myEM(ExemptionMechanismSpi spi, Provider prov, String mechanism) { + super(spi, prov, mechanism); + } + + public void finalize() { + try { + super.finalize(); + } catch (Throwable e) { + throw new RuntimeException("finalize was broken", e); + } + } +} Index: modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfo_ImplTest.java =================================================================== --- modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfo_ImplTest.java (revision 0) +++ modules/crypto/src/test/impl/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfo_ImplTest.java (revision 0) @@ -0,0 +1,123 @@ +/* + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* @author Vladimir N. Molotkov +* @version $Revision$ +*/ + +package org.apache.harmony.crypto.tests.javax.crypto; + +import java.io.IOException; +import java.security.AlgorithmParameters; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.EncryptedPrivateKeyInfo; + +import org.apache.harmony.crypto.tests.support.EncryptedPrivateKeyInfoData; + +import junit.framework.TestCase; + +/** + * Test for EncryptedPrivateKeyInfo class. + * + * All binary data for this test were generated using + * BEA JRockit j2sdk1.4.2_04 (http://www.bea.com) with + * security providers list extended by Bouncy Castle's one + * (http://www.bouncycastle.org) + */ +public class EncryptedPrivateKeyInfo_ImplTest extends TestCase { + + /** + * Test #1 for getAlgName() method
+ * Assertion: Returns the encryption algorithm name
+ * Test preconditions: test object created using ctor which takes encoded + * form as the only parameter
+ * Expected: corresponding algorithm name must be returned + * + * @throws IOException + */ + public final void testGetAlgName01() throws IOException { + boolean performed = false; + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { + try { + EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( + EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0])); + assertEquals(EncryptedPrivateKeyInfoData.algName0[i][1], epki + .getAlgName()); + performed = true; + } catch (NoSuchAlgorithmException allowed) { + } + } + assertTrue("Test not perfrormed", performed); + } + + /** + * Test #2 for getAlgName() method
+ * Assertion: Returns the encryption algorithm name
+ * Test preconditions: test object created using ctor which takes algorithm + * name and encrypted data as a parameters
+ * Expected: corresponding algorithm name must be returned + * + * @throws IOException + */ + public final void testGetAlgName02() { + boolean performed = false; + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { + try { + EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( + EncryptedPrivateKeyInfoData.algName0[i][0], + EncryptedPrivateKeyInfoData.encryptedData); + assertEquals(EncryptedPrivateKeyInfoData.algName0[i][1], epki + .getAlgName()); + performed = true; + } catch (NoSuchAlgorithmException allowedFailure) { + } + } + assertTrue("Test not perfrormed", performed); + } + + /** + * Test #3 for getAlgName() method
+ * Assertion: Returns the encryption algorithm name
+ * Test preconditions: test object created using ctor which takes + * AlgorithmParameters and encrypted data as a parameters
+ * Expected: corresponding algorithm name must be returned + * + * @throws IOException + */ + public final void testGetAlgName03() throws IOException { + boolean performed = false; + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { + try { + AlgorithmParameters ap = AlgorithmParameters + .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]); + // use pregenerated AlgorithmParameters encodings + ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0])); + EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, + EncryptedPrivateKeyInfoData.encryptedData); + assertEquals(EncryptedPrivateKeyInfoData.algName0[i][1], epki + .getAlgName()); + performed = true; + } catch (NoSuchAlgorithmException allowedFailure) { + } + } + assertTrue("Test not perfrormed", performed); + } +} Index: modules/crypto/src/test/impl/java.injected/org/apache/harmony/crypto/internal/NullCipherSpiTest.java =================================================================== --- modules/crypto/src/test/impl/java.injected/org/apache/harmony/crypto/internal/NullCipherSpiTest.java (revision 410067) +++ modules/crypto/src/test/impl/java.injected/org/apache/harmony/crypto/internal/NullCipherSpiTest.java (working copy) @@ -22,13 +22,13 @@ package org.apache.harmony.crypto.internal; import java.nio.ByteBuffer; +import java.util.Arrays; import javax.crypto.ShortBufferException; -import junit.framework.TestCase; import org.apache.harmony.crypto.internal.NullCipherSpi; +import junit.framework.TestCase; - /** * * Tests for NullCipher implementation @@ -37,23 +37,17 @@ public void testEngineGetBlockSize() { NullCipherSpi spi = new NullCipherSpi(); - if (spi.engineGetBlockSize() != 1) { - fail("incorrect block size"); - } + assertEquals("incorrect block size", 1, spi.engineGetBlockSize()); } public void testEngineGetOutputSize() { NullCipherSpi spi = new NullCipherSpi(); - if (spi.engineGetOutputSize(100) != 100) { - fail("incorrect output size"); - } + assertEquals("incorrect output size", 100, spi.engineGetOutputSize(100)); } public void testEngineGetIV() { NullCipherSpi spi = new NullCipherSpi(); - if (spi.engineGetIV() != null) { - fail("incorrect IV"); - } + assertTrue("Incorrect IV", Arrays.equals(spi.engineGetIV() , new byte[8])); } /* @@ -64,76 +58,46 @@ byte[] b = {1,2,3,4,5,6,7,8,9}; byte[] b1 = spi.engineUpdate(b, 3, 4); for (int i = 0; i < 4; i++) { - if ( b[3+i] != b1[i] ) { - fail("incorrect update result"); - } + assertEquals("incorrect update result", b[3+i], b1[i]); } } /* * Class under test for int engineUpdate(byte[], int, int, byte[], int) */ - public void testEngineUpdatebyteArrayintintbyteArrayint() { + public void testEngineUpdatebyteArrayintintbyteArrayint() throws Exception { NullCipherSpi spi = new NullCipherSpi(); byte[] b = {1,2,3,4,5,6,7,8,9}; byte[] b1 = new byte[10]; - int n = -1; - try { - n = spi.engineUpdate(b, 3, 4, b1, 5); - } catch (ShortBufferException e) { - fail(e.toString()); - } - if (n != 4) { - fail("incorrect update result"); - } + assertEquals("incorrect update result", 4, spi.engineUpdate(b, 3, 4, b1, 5)); for (int i = 0; i < 4; i++) { - if ( b[3+i] != b1[5+i] ) { - fail("incorrect update result"); - } + assertEquals("incorrect update result", b[3+i], b1[5+i]); } } /* * Class under test for byte[] engineDoFinal(byte[], int, int) */ - public void testEngineDoFinalbyteArrayintint() { + public void testEngineDoFinalbyteArrayintint() throws Exception { NullCipherSpi spi = new NullCipherSpi(); byte[] b = {1,2,3,4,5,6,7,8,9}; byte[] b1 = null; - try { - b1 = spi.engineDoFinal(b, 3, 4); - } catch (Exception e) { - fail(e.toString()); - } + b1 = spi.engineDoFinal(b, 3, 4); for (int i = 0; i < 4; i++) { - if ( b[3+i] != b1[i] ) { - fail("incorrect doFinal result"); - } + assertEquals("incorrect doFinal result", b[3+i], b1[i]); } } /* * Class under test for int engineDoFinal(byte[], int, int, byte[], int) */ - public void testEngineDoFinalbyteArrayintintbyteArrayint() { + public void testEngineDoFinalbyteArrayintintbyteArrayint() throws Exception { NullCipherSpi spi = new NullCipherSpi(); byte[] b = {1,2,3,4,5,6,7,8,9}; byte[] b1 = new byte[10]; - int n = -1; - try { - n = spi.engineDoFinal(b, 3, 4, b1, 5); - } catch (ShortBufferException e) { - fail(e.toString()); - } catch (Exception e) { - fail(e.toString()); - } - if (n != 4) { - fail("incorrect doFinal result"); - } + assertEquals("incorrect doFinal result", 4, spi.engineDoFinal(b, 3, 4, b1, 5)); for (int i = 0; i < 4; i++) { - if ( b[3+i] != b1[5+i] ) { - fail("incorrect doFinal result"); - } + assertEquals("incorrect doFinal result", b[3+i], b1[5+i]); } } @@ -141,7 +105,7 @@ /* * Class under test for int engineUpdate(ByteBuffer, ByteBuffer) */ - public void testEngineUpdateByteBufferByteBuffer() { + public void testEngineUpdateByteBufferByteBuffer() throws Exception { NullCipherSpi spi = new NullCipherSpi(); byte[] b = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; @@ -152,35 +116,22 @@ spi.engineUpdate(null, outbuf); fail("No expected NullPointerException"); } catch (NullPointerException e) { - } catch (ShortBufferException e) { - fail(e.toString()); } try { spi.engineUpdate(inbuf, null); fail("No expected NullPointerException"); } catch (NullPointerException e) { - } catch (ShortBufferException e) { - fail(e.toString()); } inbuf.get(); inbuf.get(); inbuf.get(); inbuf.get(); - int result = 0; - try { - result = spi.engineUpdate(inbuf, outbuf); - if (result != b.length - 4) { - fail("incorrect result " + result); - } - } catch (ShortBufferException e) { - fail(e.toString()); - } + int result = spi.engineUpdate(inbuf, outbuf); + assertEquals("incorrect result", b.length - 4, result); for (int i = 0; i < result; i++) { - if (outbuf.get(i) != i + 4) { - fail("incorrect outbuf"); - } + assertEquals("incorrect outbuf", i + 4, outbuf.get(i)); } inbuf = ByteBuffer.wrap(b,0,b.length); @@ -199,7 +150,7 @@ /* * Class under test for int engineDoFinal(ByteBuffer, ByteBuffer) */ - public void testEngineDoFinalByteBufferByteBuffer() { + public void testEngineDoFinalByteBufferByteBuffer() throws Exception { NullCipherSpi spi = new NullCipherSpi(); byte[] b = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; @@ -209,49 +160,24 @@ try { spi.engineDoFinal(null, outbuf); fail("No expected NullPointerException"); - } catch (NullPointerException e) { - } catch (ShortBufferException e) { - fail(e.toString()); - } catch (javax.crypto.BadPaddingException e) { - fail(e.toString()); - } catch (javax.crypto.IllegalBlockSizeException e) { - fail(e.toString()); + } catch (NullPointerException e) { } try { spi.engineDoFinal(inbuf, null); fail("No expected NullPointerException"); - } catch (NullPointerException e) { - } catch (ShortBufferException e) { - fail(e.toString()); - } catch (javax.crypto.BadPaddingException e) { - fail(e.toString()); - } catch (javax.crypto.IllegalBlockSizeException e) { - fail(e.toString()); + } catch (NullPointerException e) { } inbuf.get(); inbuf.get(); inbuf.get(); inbuf.get(); - int result = 0; - try { - result = spi.engineDoFinal(inbuf, outbuf); - if (result != b.length - 4) { - fail("incorrect result " + result); - } - } catch (ShortBufferException e) { - fail(e.toString()); - } catch (javax.crypto.BadPaddingException e) { - fail(e.toString()); - } catch (javax.crypto.IllegalBlockSizeException e) { - fail(e.toString()); - } - for (int i = 0; i < result; i++) { - if (outbuf.get(i) != i + 4) { - fail("incorrect outbuf"); - } - } + int result = spi.engineDoFinal(inbuf, outbuf); + assertEquals("incorrect result", b.length - 4, result); + for (int i = 0; i < result; i++) { + assertEquals("incorrect outbuf", i + 4, outbuf.get(i)); + } inbuf = ByteBuffer.wrap(b,0,b.length); outbuf = ByteBuffer.allocate(5); @@ -263,51 +189,42 @@ spi.engineDoFinal(inbuf, outbuf); fail("No expected ShortBufferException"); } catch (ShortBufferException e) { - } catch (javax.crypto.BadPaddingException e) { - fail(e.toString()); - } catch (javax.crypto.IllegalBlockSizeException e) { - fail(e.toString()); } } /* * Class under test for byte[] engineWrap(Key) */ - public void testEngineWrapKey() { + public void testEngineWrapKey() throws Exception { NullCipherSpi spi = new NullCipherSpi(); try { spi.engineWrap(null); fail("No expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { - } catch (Exception e) { - fail(e.toString()); - } } + } + } /* * Class under test for Key engineUnwrap(byte[], String, int) */ - public void testEngineUnwrapbyteArrayStringint() { + public void testEngineUnwrapbyteArrayStringint() throws Exception { NullCipherSpi spi = new NullCipherSpi(); try { spi.engineUnwrap(new byte[3], "", 10); fail("No expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { - } catch (Exception e) { - fail(e.toString()); } } /* * Class under test for int engineGetKeySize(Key) */ - public void testEngineGetKeySize() { + public void testEngineGetKeySize() throws Exception { NullCipherSpi spi = new NullCipherSpi(); try { spi.engineGetKeySize(null); fail("No expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { - } catch (Exception e) { - fail(e.toString()); } } Index: modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java =================================================================== --- modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java (revision 410067) +++ modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyGeneratorTest.java (working copy) @@ -43,16 +43,7 @@ * */ -public class KeyGenerator1Test extends TestCase { - - /** - * Constructor for KeyGenerator1Test. - * - * @param arg0 - */ - public KeyGenerator1Test(String arg0) { - super(arg0); - } +public class KeyGeneratorTest extends TestCase { public static final String srvKeyGenerator = "KeyGenerator"; @@ -438,9 +429,6 @@ } } - public static void main(String args[]) { - junit.textui.TestRunner.run(KeyGenerator1Test.class); - } } /** Index: modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java =================================================================== --- modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java (revision 410067) +++ modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java (working copy) @@ -47,7 +47,7 @@ * */ -public class Mac1Test extends TestCase { +public class MacTest extends TestCase { public static final String srvMac = "Mac"; @@ -100,16 +100,8 @@ return null; } } - /** - * Constructor for MacTest. - * @param arg0 - */ - public Mac1Test(String arg0) { - super(arg0); - } - /** * Test for getInstance(String algorithm) method * Assertion: * throws NullPointerException when algorithm is null @@ -791,7 +783,7 @@ } public static Test suite() { - return new TestSuite(Mac1Test.class); + return new TestSuite(MacTest.class); } public static void main(String args[]) { Index: modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java =================================================================== --- modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java (revision 410067) +++ modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/NullCipherTest.java (working copy) @@ -21,17 +21,15 @@ package org.apache.harmony.crypto.tests.javax.crypto; -import javax.crypto.BadPaddingException; +import java.security.SecureRandom; +import java.util.Arrays; + import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; import javax.crypto.NullCipher; -import javax.crypto.ShortBufferException; import javax.crypto.spec.SecretKeySpec; import junit.framework.TestCase; -import java.security.*; - /** * * Tests for NullCipher @@ -50,339 +48,156 @@ } public void testGetBlockSize() { - if (c.getBlockSize() != 1) { - fail("getBlockSize() failed"); - } + assertEquals("Incorrect BlockSize", 1, c.getBlockSize()); } public void testGetOutputSize() { - if (c.getOutputSize(111) != 111) { - fail("getOutputSize() failed"); - } + assertEquals("Incorrect OutputSize", 111, c.getOutputSize(111)); } public void testGetIV() { - if (c.getIV() != null) { - fail("getIV() failed"); - } + assertTrue("Incorrect IV", Arrays.equals(c.getIV(), new byte[8])); } public void testGetParameters() { - if (c.getParameters() != null) { - fail("getParameters() failed"); - } + assertNull("Incorrect Parameters", c.getParameters()); } public void testGetExemptionMechanism() { - if (c.getExemptionMechanism() != null) { - fail("getExemptionMechanism() failed"); - } + assertNull("Incorrect ExemptionMechanism", c.getExemptionMechanism()); } /* * Class under test for void init(int, Key) */ - public void testInitintKey() { - try { - c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1], "algorithm")); - } catch (InvalidKeyException e) { - fail(e.toString()); - } + public void testInitintKey() throws Exception { + c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1], "algorithm")); + } /* * Class under test for void init(int, Key, SecureRandom) */ - public void testInitintKeySecureRandom() { - try { - c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1], "algorithm"), new SecureRandom()); - } catch (InvalidKeyException e) { - fail(e.toString()); - } + public void testInitintKeySecureRandom() throws Exception { + c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1], + "algorithm"), new SecureRandom()); } /* * Class under test for void init(int, Key, AlgorithmParameterSpec) */ - public void testInitintKeyAlgorithmParameterSpec() { + public void testInitintKeyAlgorithmParameterSpec() throws Exception { class myAlgorithmParameterSpec implements java.security.spec.AlgorithmParameterSpec {} - try { - c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1], "algorithm"), new myAlgorithmParameterSpec()); - } catch (InvalidKeyException e) { - fail(e.toString()); - } catch (InvalidAlgorithmParameterException e) { - fail(e.toString()); - } + c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[1], + "algorithm"), new myAlgorithmParameterSpec()); } /* - * Class under test for void init(int, Key, AlgorithmParameterSpec, SecureRandom) - */ - public void testInitintKeyAlgorithmParameterSpecSecureRandom() { - } - - /* - * Class under test for void init(int, Key, AlgorithmParameters) - */ - public void testInitintKeyAlgorithmParameters() { - } - - /* - * Class under test for void init(int, Key, AlgorithmParameters, SecureRandom) - */ - public void testInitintKeyAlgorithmParametersSecureRandom() { - } - - /* - * Class under test for void init(int, Certificate) - */ - public void testInitintCertificate() { - } - - /* - * Class under test for void init(int, Certificate, SecureRandom) - */ - public void testInitintCertificateSecureRandom() { - } - - /* * Class under test for byte[] update(byte[]) */ - public void testUpdatebyteArray() { + public void testUpdatebyteArray() throws Exception { byte [] b = {1, 2, 3, 4, 5}; byte [] r = c.update(b); - if (b.length != r.length) { - fail("different length"); - } - for (int i = 0; i < b.length; i++) { - if (b[i] != r[i]) { - fail("different content"); - } - } + assertEquals("different length", b.length, r.length); + assertTrue("different content", Arrays.equals(b, r)); } /* * Class under test for byte[] update(byte[], int, int) */ - public void testUpdatebyteArrayintint() { + public void testUpdatebyteArrayintint() throws Exception { byte [] b = {1, 2, 3, 4, 5}; byte [] r = c.update(b, 0, 5); - if (b.length != r.length) { - fail("different length"); - } - for (int i = 0; i < b.length; i++) { - if (b[i] != r[i]) { - fail("different content"); - } - } + assertEquals("different length", b.length, r.length); + assertTrue("different content", Arrays.equals(b, r)); r = c.update(b, 1, 3); - if (r.length != 3) { - fail("different length"); - } + assertEquals("different length", 3, r.length); for (int i = 0; i < 3; i++) { - if (b[i + 1] != r[i]) { - fail("different content"); - } + assertEquals("different content", b[i + 1], r[i]); } } /* * Class under test for int update(byte[], int, int, byte[]) */ - public void testUpdatebyteArrayintintbyteArray() { + public void testUpdatebyteArrayintintbyteArray() throws Exception { byte [] b = {1, 2, 3, 4, 5}; byte [] r = new byte[5]; - try { - c.update(b, 0, 5, r); - } catch (ShortBufferException e) { - fail(e.toString()); - } - - for (int i = 0; i < b.length; i++) { - if (b[i] != r[i]) { - fail("different content"); - } - } + c.update(b, 0, 5, r); + assertTrue("different content", Arrays.equals(b, r)); } /* * Class under test for int update(byte[], int, int, byte[], int) */ - public void testUpdatebyteArrayintintbyteArrayint() { + public void testUpdatebyteArrayintintbyteArrayint() throws Exception { byte [] b = {1, 2, 3, 4, 5}; byte [] r = new byte[5]; - try { - c.update(b, 0, 5, r, 0); - } catch (ShortBufferException e) { - fail(e.toString()); - } - - for (int i = 0; i < b.length; i++) { - if (b[i] != r[i]) { - fail("different content"); - } - } + c.update(b, 0, 5, r, 0); + assertTrue("different content", Arrays.equals(b, r)); } /* - * Class under test for int update(ByteBuffer, ByteBuffer) - */ - public void testUpdateByteBufferByteBuffer() { - } - - /* * Class under test for byte[] doFinal() */ - public void testDoFinal() { - try { - if (c.doFinal() != null) { - fail("doFinal failed"); - } - } catch (BadPaddingException e) { - fail(e.toString()); - } catch (IllegalBlockSizeException e) { - fail(e.toString()); - } - + public void testDoFinal() throws Exception { + assertNull("doFinal failed", c.doFinal()); } /* * Class under test for int doFinal(byte[], int) */ - public void testDoFinalbyteArrayint() { + public void testDoFinalbyteArrayint() throws Exception { byte [] r = new byte[5]; - try { - if (c.doFinal(r, 0) != 0) { - fail("doFinal failed"); - } - } catch (BadPaddingException e) { - fail(e.toString()); - } catch (IllegalBlockSizeException e) { - fail(e.toString()); - } catch (ShortBufferException e) { - fail(e.toString()); - } + assertEquals("doFinal failed", 0, c.doFinal(r, 0)); } /* * Class under test for byte[] doFinal(byte[]) */ - public void testDoFinalbyteArray() { + public void testDoFinalbyteArray() throws Exception { byte [] b = {1, 2, 3, 4, 5}; byte [] r = null; - try { - r = c.doFinal(b); - } catch (BadPaddingException e) { - fail(e.toString()); - } catch (IllegalBlockSizeException e) { - fail(e.toString()); - } - if (b.length != r.length) { - fail("different length"); - } - for (int i = 0; i < b.length; i++) { - if (b[i] != r[i]) { - fail("different content"); - } - } + r = c.doFinal(b); + assertEquals("different length", b.length, r.length); + assertTrue("different content", Arrays.equals(b, r)); } /* * Class under test for byte[] doFinal(byte[], int, int) */ - public void testDoFinalbyteArrayintint() { + public void testDoFinalbyteArrayintint() throws Exception { byte [] b = {1, 2, 3, 4, 5}; byte [] r = null; - try { - r = c.doFinal(b, 0, 5); - } catch (BadPaddingException e) { - fail(e.toString()); - } catch (IllegalBlockSizeException e) { - fail(e.toString()); - } - if (b.length != r.length) { - fail("different length"); - } - for (int i = 0; i < b.length; i++) { - if (b[i] != r[i]) { - fail("different content"); - } - } + r = c.doFinal(b, 0, 5); + assertEquals("different length", b.length, r.length); + assertTrue("different content", Arrays.equals(b, r)); - try { - r = c.doFinal(b, 1, 3); - } catch (BadPaddingException e) { - fail(e.toString()); - } catch (IllegalBlockSizeException e) { - fail(e.toString()); - } - if (r.length != 3) { - fail("different length"); - } + r = c.doFinal(b, 1, 3); + assertEquals("different length", 3, r.length); for (int i = 0; i < 3; i++) { - if (b[i + 1] != r[i]) { - fail("different content"); - } + assertEquals("different content", b[i + 1], r[i]); } } /* * Class under test for int doFinal(byte[], int, int, byte[]) */ - public void testDoFinalbyteArrayintintbyteArray() { + public void testDoFinalbyteArrayintintbyteArray() throws Exception { byte [] b = {1, 2, 3, 4, 5}; byte [] r = new byte[5]; - try { - c.doFinal(b, 0, 5, r); - } catch (BadPaddingException e) { - fail(e.toString()); - } catch (ShortBufferException e) { - fail(e.toString()); - } catch (IllegalBlockSizeException e) { - fail(e.toString()); - } - - for (int i = 0; i < b.length; i++) { - if (b[i] != r[i]) { - fail("different content"); - } - } + c.doFinal(b, 0, 5, r); + assertTrue("different content", Arrays.equals(b, r)); } /* * Class under test for int doFinal(byte[], int, int, byte[], int) */ - public void testDoFinalbyteArrayintintbyteArrayint() { + public void testDoFinalbyteArrayintintbyteArrayint() throws Exception { byte [] b = {1, 2, 3, 4, 5}; byte [] r = new byte[5]; - try { - c.doFinal(b, 0, 5, r, 0); - } catch (BadPaddingException e) { - fail(e.toString()); - } catch (ShortBufferException e) { - fail(e.toString()); - } catch (IllegalBlockSizeException e) { - fail(e.toString()); - } - - for (int i = 0; i < b.length; i++) { - if (b[i] != r[i]) { - fail("different content"); - } - } + c.doFinal(b, 0, 5, r, 0); + assertTrue("different content", Arrays.equals(b, r)); } - - /* - * Class under test for int doFinal(ByteBuffer, ByteBuffer) - */ - public void testDoFinalByteBufferByteBuffer() { - } - - public void testWrap() { - } - - public void testUnwrap() { - } - } Index: modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java =================================================================== --- modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java (revision 410067) +++ modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/DESKeySpecTest.java (working copy) @@ -18,12 +18,14 @@ * @version $Revision$ */ -package javax.crypto.spec; +package org.apache.harmony.crypto.tests.javax.crypto.spec; import java.lang.NullPointerException; import java.security.InvalidKeyException; import java.util.Arrays; +import javax.crypto.spec.DESKeySpec; + import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; Index: modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java =================================================================== --- modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java (revision 410067) +++ modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherTest.java (working copy) @@ -31,6 +31,7 @@ import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SecretKeyFactory; +import javax.crypto.ShortBufferException; import javax.crypto.spec.DESedeKeySpec; import javax.crypto.spec.IvParameterSpec; @@ -38,6 +39,21 @@ public class CipherTest extends junit.framework.TestCase { + static Key cipherKey; + static final String algorithm = "DESede"; + static final int keyLen = 168; + + static { + try { + KeyGenerator kg = KeyGenerator.getInstance(algorithm); + kg.init(keyLen, new SecureRandom()); + cipherKey = kg.generateKey(); + } catch (Exception e) { + fail("No key " + e); + } + } + + /** * @tests javax.crypto.Cipher#getInstance(java.lang.String) */ @@ -148,18 +164,9 @@ * @tests javax.crypto.Cipher#getOutputSize(int) */ public void test_getOutputSizeI() throws Exception { - final String algorithm = "DESede"; - final int keyLen = 168; - Key cipherKey = null; SecureRandom sr = new SecureRandom(); - Cipher cipher = null; - - KeyGenerator kg = KeyGenerator.getInstance(algorithm); - kg.init(keyLen, new SecureRandom()); - cipherKey = kg.generateKey(); - - cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding"); + Cipher cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, cipherKey, sr); // A 25-byte input could result in at least 4 8-byte blocks @@ -172,99 +179,10 @@ } /** - * @tests javax.crypto.Cipher#getIV() - * @tests javax.crypto.Cipher#init(int, java.security.Key, - * java.security.AlgorithmParameters) - */ - public void test_getIV() throws Exception { - /* - * If this test is changed, implement the following: - * test_initILjava_security_KeyLjava_security_AlgorithmParameters() - */ - final String algorithm = "DESede"; - final int keyLen = 168; - - Key cipherKey = null; - SecureRandom sr = new SecureRandom(); - Cipher cipher = null; - - byte[] iv = null; - - KeyGenerator kg = KeyGenerator.getInstance(algorithm); - kg.init(keyLen, new SecureRandom()); - - cipherKey = kg.generateKey(); - - iv = new byte[8]; - sr.nextBytes(iv); - AlgorithmParameters ap = AlgorithmParameters.getInstance(algorithm); - ap.init(iv, "RAW"); - - cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap); - - byte[] cipherIV = cipher.getIV(); - - assertTrue("IVs differ", Arrays.equals(cipherIV, iv)); - } - - /** - * @tests javax.crypto.Cipher#getParameters() - * @tests javax.crypto.Cipher#init(int, java.security.Key, - * java.security.AlgorithmParameters, java.security.SecureRandom) - */ - public void test_getParameters() throws Exception { - - /* - * If this test is changed, implement the following: - * test_initILjava_security_KeyLjava_security_AlgorithmParametersLjava_security_SecureRandom() - */ - final String algorithm = "DESede"; - final int keyLen = 168; - - Key cipherKey = null; - SecureRandom sr = new SecureRandom(); - Cipher cipher = null; - - byte[] apEncoding = null; - - byte[] iv = null; - - KeyGenerator kg = KeyGenerator.getInstance(algorithm); - kg.init(keyLen, new SecureRandom()); - cipherKey = kg.generateKey(); - - iv = new byte[8]; - sr.nextBytes(iv); - - AlgorithmParameters ap = AlgorithmParameters.getInstance("DESede"); - ap.init(iv, "RAW"); - apEncoding = ap.getEncoded("ASN.1"); - - cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap, sr); - - byte[] cipherParmsEnc = cipher.getParameters().getEncoded("ASN.1"); - assertTrue("Parameters differ", Arrays.equals(apEncoding, - cipherParmsEnc)); - } - - /** * @tests javax.crypto.Cipher#init(int, java.security.Key) */ public void test_initILjava_security_Key() throws Exception { - final String algorithm = "DESede"; - final int keyLen = 168; - - Key cipherKey = null; - Cipher cipher = null; - - KeyGenerator kg = KeyGenerator.getInstance(algorithm); - kg.init(keyLen, new SecureRandom()); - cipherKey = kg.generateKey(); - - cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding"); - + Cipher cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, cipherKey); } @@ -274,20 +192,8 @@ */ public void test_initILjava_security_KeyLjava_security_SecureRandom() throws Exception { - - final String algorithm = "DESede"; - final int keyLen = 168; - - Key cipherKey = null; SecureRandom sr = new SecureRandom(); - Cipher cipher = null; - - KeyGenerator kg = KeyGenerator.getInstance(algorithm); - kg.init(keyLen, new SecureRandom()); - cipherKey = kg.generateKey(); - - cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding"); - + Cipher cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, cipherKey, sr); } @@ -297,21 +203,12 @@ */ public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpec() throws Exception { - - final String algorithm = "DESede"; - final int keyLen = 168; - - Key cipherKey = null; SecureRandom sr = new SecureRandom(); Cipher cipher = null; byte[] iv = null; AlgorithmParameterSpec ivAVP = null; - KeyGenerator kg = KeyGenerator.getInstance(algorithm); - kg.init(keyLen, new SecureRandom()); - cipherKey = kg.generateKey(); - iv = new byte[8]; sr.nextBytes(iv); ivAVP = new IvParameterSpec(iv); @@ -332,20 +229,12 @@ */ public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom() throws Exception { - final String algorithm = "DESede"; - final int keyLen = 168; - - Key cipherKey = null; SecureRandom sr = new SecureRandom(); Cipher cipher = null; byte[] iv = null; AlgorithmParameterSpec ivAVP = null; - KeyGenerator kg = KeyGenerator.getInstance(algorithm); - kg.init(keyLen, new SecureRandom()); - cipherKey = kg.generateKey(); - iv = new byte[8]; sr.nextBytes(iv); ivAVP = new IvParameterSpec(iv); @@ -471,4 +360,77 @@ return null; } } + + public void testGetParameters() throws Exception { + Cipher c = Cipher.getInstance("DES"); + assertNull(c.getParameters()); + } + + /* + * Class under test for int update(byte[], int, int, byte[], int) + */ + public void testUpdatebyteArrayintintbyteArrayint() throws Exception { + Cipher c = Cipher.getInstance("DESede"); + c.init(Cipher.ENCRYPT_MODE, cipherKey); + byte[] b = {1,2,3,4,5,6,7,8,9,10}; + byte[] b1 = new byte[6]; + try { + c.update(b, 0, 10, b1, 5); + fail("No expected ShortBufferException"); + } catch (ShortBufferException e) { + } + } + + /* + * Class under test for int doFinal(byte[], int, int, byte[], int) + */ + public void testDoFinalbyteArrayintintbyteArrayint() throws Exception { + Cipher c = Cipher.getInstance("DESede"); + c.init(Cipher.ENCRYPT_MODE, cipherKey); + byte[] b = {1,2,3,4,5,6,7,8,9,10}; + byte[] b1 = new byte[6]; + // FIXME Failed on BC provider + // try { + // c.doFinal(b, 3, 6, b1, 5); + // fail("No expected ShortBufferException"); + // } catch (ShortBufferException e) { + // } + } + + public void testGetMaxAllowedKeyLength() throws NoSuchAlgorithmException { + try { + Cipher.getMaxAllowedKeyLength(null); + fail("No expected NullPointerException"); + } catch (NullPointerException e) { + } + try { + Cipher.getMaxAllowedKeyLength("//CBC/PKCS5Paddin"); + fail("No expected NoSuchAlgorithmException"); + } catch (NoSuchAlgorithmException e) { + } + try { + Cipher.getMaxAllowedKeyLength("/DES/CBC/PKCS5Paddin/1"); + fail("No expected NoSuchAlgorithmException"); + } catch (NoSuchAlgorithmException e) { + } + } + + public void testGetMaxAllowedParameterSpec() + throws NoSuchAlgorithmException { + try { + Cipher.getMaxAllowedParameterSpec(null); + fail("No expected NullPointerException"); + } catch (NullPointerException e) { + } + try { + Cipher.getMaxAllowedParameterSpec("/DES//PKCS5Paddin"); + fail("No expected NoSuchAlgorithmException"); + } catch (NoSuchAlgorithmException e) { + } + try { + Cipher.getMaxAllowedParameterSpec("/DES/CBC/ /1"); + fail("No expected NoSuchAlgorithmException"); + } catch (NoSuchAlgorithmException e) { + } + } + } Index: modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java =================================================================== --- modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java (revision 410067) +++ modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/EncryptedPrivateKeyInfoTest.java (working copy) @@ -15,9 +15,9 @@ */ /** -* @author Vladimir N. Molotkov -* @version $Revision$ -*/ + * @author Vladimir N. Molotkov + * @version $Revision$ + */ package org.apache.harmony.crypto.tests.javax.crypto; @@ -35,7 +35,6 @@ import java.security.spec.InvalidParameterSpecException; import java.security.spec.PKCS8EncodedKeySpec; import java.util.Arrays; -import java.util.HashMap; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -47,1303 +46,150 @@ import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEParameterSpec; +import org.apache.harmony.crypto.tests.support.EncryptedPrivateKeyInfoData; + import junit.framework.TestCase; - /** * Test for EncryptedPrivateKeyInfo class. * - * All binary data for this test were generated using - * BEA JRockit j2sdk1.4.2_04 (http://www.bea.com) with - * security providers list extended by Bouncy Castle's one - * (http://www.bouncycastle.org) + * All binary data for this test were generated using BEA JRockit j2sdk1.4.2_04 + * (http://www.bea.com) with security providers list extended by Bouncy Castle's + * one (http://www.bouncycastle.org) */ public class EncryptedPrivateKeyInfoTest extends TestCase { - /** - * "valid" encoding for DSA with alg params - */ - private static final byte[] dsaEncryptedPrivateKeyInfo = new byte[] { - (byte) 0x30, (byte) 0x82, (byte) 0x05, (byte) 0x33, (byte) 0x30, - (byte) 0x82, (byte) 0x01, (byte) 0x2b, (byte) 0x06, (byte) 0x07, - (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0xce, (byte) 0x38, - (byte) 0x04, (byte) 0x01, (byte) 0x30, (byte) 0x82, (byte) 0x01, - (byte) 0x1e, (byte) 0x02, (byte) 0x81, (byte) 0x81, (byte) 0x00, - (byte) 0x9f, (byte) 0x5e, (byte) 0x76, (byte) 0x19, (byte) 0x59, - (byte) 0xd8, (byte) 0xf7, (byte) 0x6b, (byte) 0x91, (byte) 0x6d, - (byte) 0x15, (byte) 0x7e, (byte) 0x14, (byte) 0x27, (byte) 0x25, - (byte) 0x6e, (byte) 0x59, (byte) 0x2c, (byte) 0xec, (byte) 0x21, - (byte) 0x7a, (byte) 0xb7, (byte) 0xd4, (byte) 0xf4, (byte) 0xa0, - (byte) 0x26, (byte) 0x4e, (byte) 0x72, (byte) 0x29, (byte) 0x18, - (byte) 0x4a, (byte) 0x1c, (byte) 0x9a, (byte) 0xc9, (byte) 0xcd, - (byte) 0x85, (byte) 0x1b, (byte) 0x39, (byte) 0x41, (byte) 0x9e, - (byte) 0x58, (byte) 0x16, (byte) 0xeb, (byte) 0x20, (byte) 0x84, - (byte) 0x28, (byte) 0x2a, (byte) 0xb9, (byte) 0xce, (byte) 0xc7, - (byte) 0x6d, (byte) 0x74, (byte) 0x99, (byte) 0xfe, (byte) 0xa5, - (byte) 0xe8, (byte) 0x66, (byte) 0xe1, (byte) 0x48, (byte) 0xdd, - (byte) 0x2e, (byte) 0xcf, (byte) 0xfe, (byte) 0xb9, (byte) 0x6a, - (byte) 0x8e, (byte) 0x12, (byte) 0x4b, (byte) 0xa4, (byte) 0xa8, - (byte) 0x87, (byte) 0xd7, (byte) 0xab, (byte) 0x26, (byte) 0xd6, - (byte) 0xc3, (byte) 0xd1, (byte) 0x3b, (byte) 0x95, (byte) 0xc4, - (byte) 0x97, (byte) 0x2c, (byte) 0xdc, (byte) 0xab, (byte) 0x5d, - (byte) 0xf5, (byte) 0x55, (byte) 0xae, (byte) 0x58, (byte) 0x68, - (byte) 0x84, (byte) 0x41, (byte) 0x99, (byte) 0x1b, (byte) 0xd3, - (byte) 0xd0, (byte) 0xd9, (byte) 0xd3, (byte) 0xdd, (byte) 0xf5, - (byte) 0x48, (byte) 0x04, (byte) 0xa2, (byte) 0x92, (byte) 0x61, - (byte) 0xf8, (byte) 0xb1, (byte) 0xe6, (byte) 0x24, (byte) 0x65, - (byte) 0x8f, (byte) 0xa4, (byte) 0x97, (byte) 0x40, (byte) 0x1d, - (byte) 0x3f, (byte) 0x2b, (byte) 0x85, (byte) 0x00, (byte) 0xd5, - (byte) 0xcb, (byte) 0x8d, (byte) 0x66, (byte) 0x9a, (byte) 0xac, - (byte) 0x7b, (byte) 0x5f, (byte) 0xc7, (byte) 0x02, (byte) 0x15, - (byte) 0x00, (byte) 0x9a, (byte) 0xfb, (byte) 0x6f, (byte) 0x72, - (byte) 0x15, (byte) 0x01, (byte) 0x03, (byte) 0x16, (byte) 0x2a, - (byte) 0xd6, (byte) 0xca, (byte) 0x60, (byte) 0x10, (byte) 0x47, - (byte) 0xde, (byte) 0x4b, (byte) 0x0f, (byte) 0xd6, (byte) 0x73, - (byte) 0x37, (byte) 0x02, (byte) 0x81, (byte) 0x80, (byte) 0x5d, - (byte) 0x51, (byte) 0x28, (byte) 0x64, (byte) 0xb2, (byte) 0x2b, - (byte) 0xeb, (byte) 0x85, (byte) 0xb4, (byte) 0x14, (byte) 0x0d, - (byte) 0xad, (byte) 0xec, (byte) 0xc8, (byte) 0x1f, (byte) 0x96, - (byte) 0x1e, (byte) 0x6a, (byte) 0x52, (byte) 0xd4, (byte) 0x0b, - (byte) 0x69, (byte) 0xb0, (byte) 0x33, (byte) 0xa1, (byte) 0xd1, - (byte) 0xbc, (byte) 0x64, (byte) 0xd6, (byte) 0x64, (byte) 0xef, - (byte) 0x2c, (byte) 0x89, (byte) 0xc7, (byte) 0x39, (byte) 0x75, - (byte) 0x87, (byte) 0x82, (byte) 0x61, (byte) 0xbe, (byte) 0xd1, - (byte) 0xcd, (byte) 0x70, (byte) 0x41, (byte) 0x85, (byte) 0x99, - (byte) 0x55, (byte) 0x75, (byte) 0x6f, (byte) 0x16, (byte) 0xc0, - (byte) 0x40, (byte) 0xf1, (byte) 0x0c, (byte) 0x78, (byte) 0x1f, - (byte) 0xe8, (byte) 0x63, (byte) 0x5d, (byte) 0xfa, (byte) 0x37, - (byte) 0xc1, (byte) 0xce, (byte) 0x97, (byte) 0x76, (byte) 0xa5, - (byte) 0x48, (byte) 0x5b, (byte) 0x88, (byte) 0xe4, (byte) 0xd5, - (byte) 0xb8, (byte) 0x06, (byte) 0xf5, (byte) 0x7f, (byte) 0x92, - (byte) 0xda, (byte) 0x99, (byte) 0xa5, (byte) 0x5a, (byte) 0x64, - (byte) 0xc9, (byte) 0x30, (byte) 0x2c, (byte) 0x77, (byte) 0x58, - (byte) 0x60, (byte) 0xa6, (byte) 0x35, (byte) 0x1d, (byte) 0x71, - (byte) 0xfb, (byte) 0x49, (byte) 0x24, (byte) 0x6c, (byte) 0x34, - (byte) 0x29, (byte) 0xa0, (byte) 0x47, (byte) 0xf1, (byte) 0x14, - (byte) 0xad, (byte) 0xc2, (byte) 0x85, (byte) 0x41, (byte) 0xdd, - (byte) 0x2c, (byte) 0x78, (byte) 0x2a, (byte) 0x5a, (byte) 0x24, - (byte) 0x7f, (byte) 0x19, (byte) 0xf4, (byte) 0x0a, (byte) 0x2e, - (byte) 0x1d, (byte) 0x92, (byte) 0x80, (byte) 0xe5, (byte) 0xe4, - (byte) 0x05, (byte) 0x28, (byte) 0x48, (byte) 0x5c, // 38 - (byte) 0x34, (byte) 0xc8, (byte) 0x22, (byte) 0x04, (byte) 0x82, - (byte) 0x04, (byte) 0x00, (byte) 0x00, // - (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, - (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a, - (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, - (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14, - (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19, - (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, - (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23, - (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28, - (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, - (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32, - (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37, - (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, - (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41, - (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46, - (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b, - (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50, - (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55, - (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a, - (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, - (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64, - (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69, - (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, - (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73, - (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78, - (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, - (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82, - (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87, - (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, - (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91, - (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96, - (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b, - (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, - (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, - (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, - (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf, - (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, - (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, - (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, - (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, - (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, - (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, - (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, - (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, - (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc, - (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, - (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, - (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb, - (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0, - (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, - (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, - (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff, - (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, - (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, - (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, - (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, - (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, - (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, - (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, - (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, - (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, - (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, - (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, - (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, - (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, - (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, - (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, - (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, - (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, - (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, - (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, - (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, - (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, - (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, - (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, - (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, - (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, - (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, - (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, - (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, - (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, - (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, - (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, - (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, - (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, - (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, - (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, - (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, - (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, - (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, - (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, - (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, - (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, - (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, - (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, - (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, - (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, - (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, - (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, - (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, - (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, - (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, - (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, - (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, - (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, - (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, - (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12, - (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17, - (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, - (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21, - (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, - (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b, - (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30, - (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, - (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, - (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, - (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, - (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, - (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, - (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53, - (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, - (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, - (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62, - (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, - (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, - (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71, - (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, - (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b, - (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80, - (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, - (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, - (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, - (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94, - (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, - (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, - (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, - (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, - (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad, - (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, - (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, - (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc, - (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, - (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, - (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb, - (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0, - (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, - (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, - (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf, - (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, - (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, - (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee, - (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, - (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, - (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, - (byte) 0xfe, (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02, - (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, - (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, - (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, - (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, - (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, - (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, - (byte) 0x21, (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, - (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, - (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, - (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, - (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, - (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, - (byte) 0x3f, (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, - (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, - (byte) 0x49, (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, - (byte) 0x4e, (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, - (byte) 0x53, (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, - (byte) 0x58, (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, - (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, - (byte) 0x62, (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, - (byte) 0x67, (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, - (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, - (byte) 0x71, (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, - (byte) 0x76, (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, - (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, - (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, - (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, - (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, - (byte) 0x8f, (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, - (byte) 0x94, (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, - (byte) 0x99, (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, - (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, - (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, - (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, - (byte) 0xad, (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, - (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, - (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, - (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, - (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, - (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, - (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, - (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, - (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, - (byte) 0xda, (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, - (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, - (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, - (byte) 0xe9, (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, - (byte) 0xee, (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, - (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, - (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, - (byte) 0xfd, (byte) 0xfe, (byte) 0xff }; - - /** - * "valid" encoding for DSA - no alg params - */ - private static final byte[] dsaEncryptedPrivateKeyInfoNP = new byte[] { - (byte) 0x30, (byte) 0x82, (byte) 0x04, (byte) 0x11, (byte) 0x30, - (byte) 0x0b, (byte) 0x06, (byte) 0x07, (byte) 0x2a, (byte) 0x86, - (byte) 0x48, (byte) 0xce, (byte) 0x38, (byte) 0x04, (byte) 0x01, - (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x82, (byte) 0x04, - (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, - (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, - (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, - (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12, - (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17, - (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, - (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21, - (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, - (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b, - (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30, - (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, - (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, - (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, - (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, - (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, - (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, - (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53, - (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, - (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, - (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62, - (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, - (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, - (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71, - (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, - (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b, - (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80, - (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, - (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, - (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, - (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94, - (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, - (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, - (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, - (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, - (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad, - (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, - (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, - (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc, - (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, - (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, - (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb, - (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0, - (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, - (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, - (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf, - (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, - (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, - (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee, - (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, - (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, - (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, - (byte) 0xfe, (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02, - (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, - (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, - (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, - (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, - (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, - (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, - (byte) 0x21, (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, - (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, - (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, - (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, - (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, - (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, - (byte) 0x3f, (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, - (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, - (byte) 0x49, (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, - (byte) 0x4e, (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, - (byte) 0x53, (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, - (byte) 0x58, (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, - (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, - (byte) 0x62, (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, - (byte) 0x67, (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, - (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, - (byte) 0x71, (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, - (byte) 0x76, (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, - (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, - (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, - (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, - (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, - (byte) 0x8f, (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, - (byte) 0x94, (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, - (byte) 0x99, (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, - (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, - (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, - (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, - (byte) 0xad, (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, - (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, - (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, - (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, - (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, - (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, - (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, - (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, - (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, - (byte) 0xda, (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, - (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, - (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, - (byte) 0xe9, (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, - (byte) 0xee, (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, - (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, - (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, - (byte) 0xfd, (byte) 0xfe, (byte) 0xff, (byte) 0x00, (byte) 0x01, - (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, - (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b, - (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, (byte) 0x10, - (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15, - (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a, - (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, - (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23, (byte) 0x24, - (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29, - (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, - (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33, - (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38, - (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, - (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41, (byte) 0x42, - (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x47, - (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, - (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50, (byte) 0x51, - (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55, (byte) 0x56, - (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a, (byte) 0x5b, - (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, (byte) 0x60, - (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64, (byte) 0x65, - (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69, (byte) 0x6a, - (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, - (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73, (byte) 0x74, - (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78, (byte) 0x79, - (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, - (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83, - (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88, - (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, - (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91, (byte) 0x92, - (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96, (byte) 0x97, - (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, - (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, - (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, - (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, (byte) 0xab, - (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf, (byte) 0xb0, - (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, - (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, (byte) 0xba, - (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, - (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, - (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, - (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, (byte) 0xce, - (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, - (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, - (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, - (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, - (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, - (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb, (byte) 0xec, - (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0, (byte) 0xf1, - (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, - (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, - (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff, (byte) 0x00, - (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, - (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a, - (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, - (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14, - (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19, - (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, - (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23, - (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28, - (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, - (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32, - (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37, - (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, - (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41, - (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46, - (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b, - (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50, - (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55, - (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a, - (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, - (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64, - (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69, - (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, - (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73, - (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78, - (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, - (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82, - (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87, - (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, - (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91, - (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96, - (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b, - (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, - (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, - (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, - (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf, - (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, - (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, - (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, - (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, - (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, - (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, - (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, - (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, - (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc, - (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, - (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, - (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb, - (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0, - (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, - (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, - (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff, }; - - /** - * "valid" encoding for DH with alg params - */ - private static final byte[] dhEncryptedPrivateKeyInfo = new byte[] { - (byte) 0x30, (byte) 0x82, (byte) 0x05, (byte) 0x22, (byte) 0x30, - (byte) 0x82, (byte) 0x01, (byte) 0x1a, (byte) 0x06, (byte) 0x09, - (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, - (byte) 0x0d, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x30, - (byte) 0x82, (byte) 0x01, (byte) 0x0b, (byte) 0x02, (byte) 0x81, - (byte) 0x81, (byte) 0x00, (byte) 0xce, (byte) 0x2c, (byte) 0x4f, - (byte) 0xea, (byte) 0xf2, (byte) 0x83, (byte) 0xc5, (byte) 0x38, - (byte) 0xc9, (byte) 0xb6, (byte) 0xd4, (byte) 0xf8, (byte) 0xb8, - (byte) 0x17, (byte) 0xa1, (byte) 0x7d, (byte) 0x4c, (byte) 0xec, - (byte) 0x6b, (byte) 0xd7, (byte) 0xc2, (byte) 0x1a, (byte) 0x35, - (byte) 0x85, (byte) 0x54, (byte) 0x14, (byte) 0x6c, (byte) 0x52, - (byte) 0x24, (byte) 0xbf, (byte) 0xe6, (byte) 0x32, (byte) 0xd8, - (byte) 0x42, (byte) 0xac, (byte) 0xb3, (byte) 0x28, (byte) 0x4f, - (byte) 0x77, (byte) 0xf6, (byte) 0xfc, (byte) 0xea, (byte) 0xea, - (byte) 0x72, (byte) 0xcf, (byte) 0x1d, (byte) 0x7b, (byte) 0xe1, - (byte) 0x72, (byte) 0xfa, (byte) 0x77, (byte) 0x12, (byte) 0xa9, - (byte) 0x42, (byte) 0xba, (byte) 0xc4, (byte) 0xf4, (byte) 0xfb, - (byte) 0xbd, (byte) 0x9f, (byte) 0x63, (byte) 0x9a, (byte) 0x58, - (byte) 0x6b, (byte) 0xb6, (byte) 0xa2, (byte) 0x6e, (byte) 0x3a, - (byte) 0x71, (byte) 0xf3, (byte) 0x43, (byte) 0x5e, (byte) 0x6f, - (byte) 0x8a, (byte) 0xd0, (byte) 0xac, (byte) 0xe5, (byte) 0x60, - (byte) 0x76, (byte) 0x57, (byte) 0x1f, (byte) 0x83, (byte) 0x4d, - (byte) 0xbc, (byte) 0xaa, (byte) 0xb1, (byte) 0x18, (byte) 0x40, - (byte) 0x19, (byte) 0xac, (byte) 0x31, (byte) 0xd4, (byte) 0xfc, - (byte) 0x39, (byte) 0x01, (byte) 0x46, (byte) 0xab, (byte) 0xab, - (byte) 0x53, (byte) 0x19, (byte) 0x2d, (byte) 0xf8, (byte) 0x4c, - (byte) 0xd3, (byte) 0x9f, (byte) 0x4d, (byte) 0xa6, (byte) 0x71, - (byte) 0x92, (byte) 0x06, (byte) 0xc7, (byte) 0x89, (byte) 0x70, - (byte) 0xc4, (byte) 0xc6, (byte) 0xa2, (byte) 0x1f, (byte) 0x05, - (byte) 0x4a, (byte) 0x5b, (byte) 0x84, (byte) 0xf9, (byte) 0xfb, - (byte) 0x98, (byte) 0x63, (byte) 0xc9, (byte) 0x9c, (byte) 0x13, - (byte) 0x02, (byte) 0x81, (byte) 0x80, (byte) 0x36, (byte) 0x55, - (byte) 0x93, (byte) 0xb3, (byte) 0x22, (byte) 0x0c, (byte) 0xcd, - (byte) 0x7c, (byte) 0xc3, (byte) 0xe3, (byte) 0xa3, (byte) 0x8a, - (byte) 0xd7, (byte) 0xb4, (byte) 0xe9, (byte) 0xe0, (byte) 0xfa, - (byte) 0xa9, (byte) 0xa8, (byte) 0x69, (byte) 0xd6, (byte) 0xa6, - (byte) 0x20, (byte) 0xb8, (byte) 0xd4, (byte) 0xe7, (byte) 0x87, - (byte) 0x4e, (byte) 0xf3, (byte) 0x90, (byte) 0x10, (byte) 0xdd, - (byte) 0x75, (byte) 0x5d, (byte) 0xff, (byte) 0xee, (byte) 0xf0, - (byte) 0xef, (byte) 0x6a, (byte) 0x0a, (byte) 0xb0, (byte) 0xf1, - (byte) 0x8a, (byte) 0xb6, (byte) 0x7b, (byte) 0x39, (byte) 0x95, - (byte) 0xd5, (byte) 0x24, (byte) 0x83, (byte) 0x10, (byte) 0x95, - (byte) 0x34, (byte) 0x08, (byte) 0x77, (byte) 0x1d, (byte) 0xaf, - (byte) 0x69, (byte) 0xf0, (byte) 0xb5, (byte) 0xdb, (byte) 0x24, - (byte) 0x89, (byte) 0x72, (byte) 0xb2, (byte) 0x0d, (byte) 0x57, - (byte) 0x94, (byte) 0xb0, (byte) 0xe8, (byte) 0xc2, (byte) 0x37, - (byte) 0x45, (byte) 0x5a, (byte) 0xfc, (byte) 0xa1, (byte) 0xa0, - (byte) 0x41, (byte) 0xe4, (byte) 0x0c, (byte) 0xa3, (byte) 0x40, - (byte) 0x8b, (byte) 0x9c, (byte) 0x19, (byte) 0x63, (byte) 0x61, - (byte) 0xd9, (byte) 0x05, (byte) 0xbf, (byte) 0xc5, (byte) 0xe8, - (byte) 0xf7, (byte) 0xbd, (byte) 0x3a, (byte) 0xf5, (byte) 0x78, - (byte) 0xc2, (byte) 0x92, (byte) 0xe8, (byte) 0x60, (byte) 0x07, - (byte) 0x3e, (byte) 0x57, (byte) 0x12, (byte) 0xf6, (byte) 0x97, - (byte) 0x1f, (byte) 0xea, (byte) 0x02, (byte) 0xa3, (byte) 0x19, - (byte) 0xa7, (byte) 0x5a, (byte) 0x9b, (byte) 0xf6, (byte) 0xd2, - (byte) 0x0f, (byte) 0xe9, (byte) 0x6b, (byte) 0xeb, (byte) 0xd7, - (byte) 0x93, (byte) 0x9a, (byte) 0x7e, (byte) 0x4f, (byte) 0xd6, - (byte) 0x29, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0xff, - (byte) 0x04, (byte) 0x82, (byte) 0x04, (byte) 0x00, (byte) 0x00, - (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, - (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a, - (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, - (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14, - (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19, - (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, - (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23, - (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28, - (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, - (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32, - (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37, - (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, - (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41, - (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46, - (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b, - (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50, - (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55, - (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a, - (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, - (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64, - (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69, - (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, - (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73, - (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78, - (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, - (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82, - (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87, - (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, - (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91, - (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96, - (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b, - (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, - (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, - (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, - (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf, - (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, - (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, - (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, - (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, - (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, - (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, - (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, - (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, - (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc, - (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, - (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, - (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb, - (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0, - (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, - (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, - (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff, - (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, - (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, - (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, - (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, - (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, - (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, - (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, - (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, - (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, - (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, - (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, - (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, - (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, - (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, - (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, - (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, - (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, - (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, - (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, - (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, - (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, - (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, - (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, - (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, - (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, - (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, - (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, - (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, - (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, - (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, - (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, - (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, - (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, - (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, - (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, - (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, - (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, - (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, - (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, - (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, - (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, - (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, - (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, - (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, - (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, - (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, - (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, - (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, - (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, - (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, - (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, - (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, - (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, - (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, - (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12, - (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17, - (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, - (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21, - (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, - (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b, - (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30, - (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, - (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, - (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, - (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, - (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, - (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, - (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53, - (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, - (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, - (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62, - (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, - (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, - (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71, - (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, - (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b, - (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80, - (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, - (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, - (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, - (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94, - (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, - (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, - (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, - (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, - (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad, - (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, - (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, - (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc, - (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, - (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, - (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb, - (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0, - (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, - (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, - (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf, - (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, - (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, - (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee, - (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, - (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, - (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, - (byte) 0xfe, (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02, - (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, - (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, - (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, - (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, - (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, - (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, - (byte) 0x21, (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, - (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, - (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, - (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, - (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, - (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, - (byte) 0x3f, (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, - (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, - (byte) 0x49, (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, - (byte) 0x4e, (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, - (byte) 0x53, (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, - (byte) 0x58, (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, - (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, - (byte) 0x62, (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, - (byte) 0x67, (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, - (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, - (byte) 0x71, (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, - (byte) 0x76, (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, - (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, - (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, - (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, - (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, - (byte) 0x8f, (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, - (byte) 0x94, (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, - (byte) 0x99, (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, - (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, - (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, - (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, - (byte) 0xad, (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, - (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, - (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, - (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, - (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, - (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, - (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, - (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, - (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, - (byte) 0xda, (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, - (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, - (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, - (byte) 0xe9, (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, - (byte) 0xee, (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, - (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, - (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, - (byte) 0xfd, (byte) 0xfe, (byte) 0xff }; - - /** - * "valid" encoding for DH - no alg params - */ - private static final byte[] dhEncryptedPrivateKeyInfoNP = new byte[] { - (byte) 0x30, (byte) 0x82, (byte) 0x04, (byte) 0x13, (byte) 0x30, - (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a, (byte) 0x86, - (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01, - (byte) 0x03, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x04, - (byte) 0x82, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x01, - (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, - (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a, (byte) 0x0b, - (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, (byte) 0x10, - (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14, (byte) 0x15, - (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19, (byte) 0x1a, - (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, - (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23, (byte) 0x24, - (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28, (byte) 0x29, - (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, - (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33, - (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38, - (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, - (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41, (byte) 0x42, - (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x47, - (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, - (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50, (byte) 0x51, - (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55, (byte) 0x56, - (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a, (byte) 0x5b, - (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, (byte) 0x60, - (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64, (byte) 0x65, - (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69, (byte) 0x6a, - (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, - (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73, (byte) 0x74, - (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78, (byte) 0x79, - (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, - (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82, (byte) 0x83, - (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87, (byte) 0x88, - (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, - (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91, (byte) 0x92, - (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96, (byte) 0x97, - (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, - (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, - (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, - (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, (byte) 0xab, - (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf, (byte) 0xb0, - (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, - (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, (byte) 0xba, - (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, - (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, - (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, - (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, (byte) 0xce, - (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, - (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, - (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, - (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, - (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, - (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb, (byte) 0xec, - (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0, (byte) 0xf1, - (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, - (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, - (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff, (byte) 0x00, - (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, - (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x0a, - (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f, - (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, (byte) 0x14, - (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, (byte) 0x19, - (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, (byte) 0x1e, - (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, (byte) 0x23, - (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28, - (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, (byte) 0x2d, - (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, (byte) 0x32, - (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37, - (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, (byte) 0x3c, - (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, (byte) 0x41, - (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46, - (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, (byte) 0x4b, - (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, (byte) 0x50, - (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, (byte) 0x55, - (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, (byte) 0x5a, - (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, (byte) 0x5f, - (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x64, - (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, (byte) 0x69, - (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, (byte) 0x6e, - (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, (byte) 0x73, - (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, (byte) 0x78, - (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, (byte) 0x7d, - (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, (byte) 0x82, - (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, (byte) 0x87, - (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, (byte) 0x8c, - (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, (byte) 0x91, - (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, (byte) 0x96, - (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, (byte) 0x9b, - (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, (byte) 0xa0, - (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, (byte) 0xa5, - (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, (byte) 0xaa, - (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, (byte) 0xaf, - (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, (byte) 0xb4, - (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, (byte) 0xb9, - (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, (byte) 0xbe, - (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, (byte) 0xc3, - (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, (byte) 0xc8, - (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, (byte) 0xcd, - (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, (byte) 0xd2, - (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, (byte) 0xd7, - (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, (byte) 0xdc, - (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, (byte) 0xe1, - (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, (byte) 0xe6, - (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, (byte) 0xeb, - (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, (byte) 0xf0, - (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, (byte) 0xf5, - (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, (byte) 0xfa, - (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, (byte) 0xff, - (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, - (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, - (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, - (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13, - (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17, (byte) 0x18, - (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, (byte) 0x1d, - (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21, (byte) 0x22, - (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, - (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b, (byte) 0x2c, - (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30, (byte) 0x31, - (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, - (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, (byte) 0x3b, - (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, (byte) 0x40, - (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, - (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, (byte) 0x4a, - (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, (byte) 0x4f, - (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53, (byte) 0x54, - (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, (byte) 0x59, - (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, (byte) 0x5e, - (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62, (byte) 0x63, - (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, (byte) 0x68, - (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, (byte) 0x6d, - (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71, (byte) 0x72, - (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, (byte) 0x77, - (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b, (byte) 0x7c, - (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80, (byte) 0x81, - (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, (byte) 0x86, - (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, (byte) 0x8b, - (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, (byte) 0x90, - (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94, (byte) 0x95, - (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, (byte) 0x9a, - (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, (byte) 0x9f, - (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, (byte) 0xa4, - (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, (byte) 0xa9, - (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad, (byte) 0xae, - (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, (byte) 0xb3, - (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, (byte) 0xb8, - (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc, (byte) 0xbd, - (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, (byte) 0xc2, - (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, (byte) 0xc7, - (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb, (byte) 0xcc, - (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0, (byte) 0xd1, - (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, (byte) 0xd6, - (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, (byte) 0xdb, - (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf, (byte) 0xe0, - (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, (byte) 0xe5, - (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, (byte) 0xea, - (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee, (byte) 0xef, - (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, (byte) 0xf4, - (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, (byte) 0xf9, - (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, (byte) 0xfe, - (byte) 0xff, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, - (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, - (byte) 0x09, (byte) 0x0a, (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, - (byte) 0x0e, (byte) 0x0f, (byte) 0x10, (byte) 0x11, (byte) 0x12, - (byte) 0x13, (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17, - (byte) 0x18, (byte) 0x19, (byte) 0x1a, (byte) 0x1b, (byte) 0x1c, - (byte) 0x1d, (byte) 0x1e, (byte) 0x1f, (byte) 0x20, (byte) 0x21, - (byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, - (byte) 0x27, (byte) 0x28, (byte) 0x29, (byte) 0x2a, (byte) 0x2b, - (byte) 0x2c, (byte) 0x2d, (byte) 0x2e, (byte) 0x2f, (byte) 0x30, - (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, - (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x3a, - (byte) 0x3b, (byte) 0x3c, (byte) 0x3d, (byte) 0x3e, (byte) 0x3f, - (byte) 0x40, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, - (byte) 0x45, (byte) 0x46, (byte) 0x47, (byte) 0x48, (byte) 0x49, - (byte) 0x4a, (byte) 0x4b, (byte) 0x4c, (byte) 0x4d, (byte) 0x4e, - (byte) 0x4f, (byte) 0x50, (byte) 0x51, (byte) 0x52, (byte) 0x53, - (byte) 0x54, (byte) 0x55, (byte) 0x56, (byte) 0x57, (byte) 0x58, - (byte) 0x59, (byte) 0x5a, (byte) 0x5b, (byte) 0x5c, (byte) 0x5d, - (byte) 0x5e, (byte) 0x5f, (byte) 0x60, (byte) 0x61, (byte) 0x62, - (byte) 0x63, (byte) 0x64, (byte) 0x65, (byte) 0x66, (byte) 0x67, - (byte) 0x68, (byte) 0x69, (byte) 0x6a, (byte) 0x6b, (byte) 0x6c, - (byte) 0x6d, (byte) 0x6e, (byte) 0x6f, (byte) 0x70, (byte) 0x71, - (byte) 0x72, (byte) 0x73, (byte) 0x74, (byte) 0x75, (byte) 0x76, - (byte) 0x77, (byte) 0x78, (byte) 0x79, (byte) 0x7a, (byte) 0x7b, - (byte) 0x7c, (byte) 0x7d, (byte) 0x7e, (byte) 0x7f, (byte) 0x80, - (byte) 0x81, (byte) 0x82, (byte) 0x83, (byte) 0x84, (byte) 0x85, - (byte) 0x86, (byte) 0x87, (byte) 0x88, (byte) 0x89, (byte) 0x8a, - (byte) 0x8b, (byte) 0x8c, (byte) 0x8d, (byte) 0x8e, (byte) 0x8f, - (byte) 0x90, (byte) 0x91, (byte) 0x92, (byte) 0x93, (byte) 0x94, - (byte) 0x95, (byte) 0x96, (byte) 0x97, (byte) 0x98, (byte) 0x99, - (byte) 0x9a, (byte) 0x9b, (byte) 0x9c, (byte) 0x9d, (byte) 0x9e, - (byte) 0x9f, (byte) 0xa0, (byte) 0xa1, (byte) 0xa2, (byte) 0xa3, - (byte) 0xa4, (byte) 0xa5, (byte) 0xa6, (byte) 0xa7, (byte) 0xa8, - (byte) 0xa9, (byte) 0xaa, (byte) 0xab, (byte) 0xac, (byte) 0xad, - (byte) 0xae, (byte) 0xaf, (byte) 0xb0, (byte) 0xb1, (byte) 0xb2, - (byte) 0xb3, (byte) 0xb4, (byte) 0xb5, (byte) 0xb6, (byte) 0xb7, - (byte) 0xb8, (byte) 0xb9, (byte) 0xba, (byte) 0xbb, (byte) 0xbc, - (byte) 0xbd, (byte) 0xbe, (byte) 0xbf, (byte) 0xc0, (byte) 0xc1, - (byte) 0xc2, (byte) 0xc3, (byte) 0xc4, (byte) 0xc5, (byte) 0xc6, - (byte) 0xc7, (byte) 0xc8, (byte) 0xc9, (byte) 0xca, (byte) 0xcb, - (byte) 0xcc, (byte) 0xcd, (byte) 0xce, (byte) 0xcf, (byte) 0xd0, - (byte) 0xd1, (byte) 0xd2, (byte) 0xd3, (byte) 0xd4, (byte) 0xd5, - (byte) 0xd6, (byte) 0xd7, (byte) 0xd8, (byte) 0xd9, (byte) 0xda, - (byte) 0xdb, (byte) 0xdc, (byte) 0xdd, (byte) 0xde, (byte) 0xdf, - (byte) 0xe0, (byte) 0xe1, (byte) 0xe2, (byte) 0xe3, (byte) 0xe4, - (byte) 0xe5, (byte) 0xe6, (byte) 0xe7, (byte) 0xe8, (byte) 0xe9, - (byte) 0xea, (byte) 0xeb, (byte) 0xec, (byte) 0xed, (byte) 0xee, - (byte) 0xef, (byte) 0xf0, (byte) 0xf1, (byte) 0xf2, (byte) 0xf3, - (byte) 0xf4, (byte) 0xf5, (byte) 0xf6, (byte) 0xf7, (byte) 0xf8, - (byte) 0xf9, (byte) 0xfa, (byte) 0xfb, (byte) 0xfc, (byte) 0xfd, - (byte) 0xfe, (byte) 0xff, }; - - /** - * Valid DSA parameters encoding - */ - public static byte[] dsaParamsEncoded = { (byte) 0x30, (byte) 0x82, - (byte) 0x01, (byte) 0x1e, (byte) 0x02, (byte) 0x81, (byte) 0x81, - (byte) 0x00, (byte) 0x9f, (byte) 0x5e, (byte) 0x76, (byte) 0x19, - (byte) 0x59, (byte) 0xd8, (byte) 0xf7, (byte) 0x6b, (byte) 0x91, - (byte) 0x6d, (byte) 0x15, (byte) 0x7e, (byte) 0x14, (byte) 0x27, - (byte) 0x25, (byte) 0x6e, (byte) 0x59, (byte) 0x2c, (byte) 0xec, - (byte) 0x21, (byte) 0x7a, (byte) 0xb7, (byte) 0xd4, (byte) 0xf4, - (byte) 0xa0, (byte) 0x26, (byte) 0x4e, (byte) 0x72, (byte) 0x29, - (byte) 0x18, (byte) 0x4a, (byte) 0x1c, (byte) 0x9a, (byte) 0xc9, - (byte) 0xcd, (byte) 0x85, (byte) 0x1b, (byte) 0x39, (byte) 0x41, - (byte) 0x9e, (byte) 0x58, (byte) 0x16, (byte) 0xeb, (byte) 0x20, - (byte) 0x84, (byte) 0x28, (byte) 0x2a, (byte) 0xb9, (byte) 0xce, - (byte) 0xc7, (byte) 0x6d, (byte) 0x74, (byte) 0x99, (byte) 0xfe, - (byte) 0xa5, (byte) 0xe8, (byte) 0x66, (byte) 0xe1, (byte) 0x48, - (byte) 0xdd, (byte) 0x2e, (byte) 0xcf, (byte) 0xfe, (byte) 0xb9, - (byte) 0x6a, (byte) 0x8e, (byte) 0x12, (byte) 0x4b, (byte) 0xa4, - (byte) 0xa8, (byte) 0x87, (byte) 0xd7, (byte) 0xab, (byte) 0x26, - (byte) 0xd6, (byte) 0xc3, (byte) 0xd1, (byte) 0x3b, (byte) 0x95, - (byte) 0xc4, (byte) 0x97, (byte) 0x2c, (byte) 0xdc, (byte) 0xab, - (byte) 0x5d, (byte) 0xf5, (byte) 0x55, (byte) 0xae, (byte) 0x58, - (byte) 0x68, (byte) 0x84, (byte) 0x41, (byte) 0x99, (byte) 0x1b, - (byte) 0xd3, (byte) 0xd0, (byte) 0xd9, (byte) 0xd3, (byte) 0xdd, - (byte) 0xf5, (byte) 0x48, (byte) 0x04, (byte) 0xa2, (byte) 0x92, - (byte) 0x61, (byte) 0xf8, (byte) 0xb1, (byte) 0xe6, (byte) 0x24, - (byte) 0x65, (byte) 0x8f, (byte) 0xa4, (byte) 0x97, (byte) 0x40, - (byte) 0x1d, (byte) 0x3f, (byte) 0x2b, (byte) 0x85, (byte) 0x00, - (byte) 0xd5, (byte) 0xcb, (byte) 0x8d, (byte) 0x66, (byte) 0x9a, - (byte) 0xac, (byte) 0x7b, (byte) 0x5f, (byte) 0xc7, (byte) 0x02, - (byte) 0x15, (byte) 0x00, (byte) 0x9a, (byte) 0xfb, (byte) 0x6f, - (byte) 0x72, (byte) 0x15, (byte) 0x01, (byte) 0x03, (byte) 0x16, - (byte) 0x2a, (byte) 0xd6, (byte) 0xca, (byte) 0x60, (byte) 0x10, - (byte) 0x47, (byte) 0xde, (byte) 0x4b, (byte) 0x0f, (byte) 0xd6, - (byte) 0x73, (byte) 0x37, (byte) 0x02, (byte) 0x81, (byte) 0x80, - (byte) 0x5d, (byte) 0x51, (byte) 0x28, (byte) 0x64, (byte) 0xb2, - (byte) 0x2b, (byte) 0xeb, (byte) 0x85, (byte) 0xb4, (byte) 0x14, - (byte) 0x0d, (byte) 0xad, (byte) 0xec, (byte) 0xc8, (byte) 0x1f, - (byte) 0x96, (byte) 0x1e, (byte) 0x6a, (byte) 0x52, (byte) 0xd4, - (byte) 0x0b, (byte) 0x69, (byte) 0xb0, (byte) 0x33, (byte) 0xa1, - (byte) 0xd1, (byte) 0xbc, (byte) 0x64, (byte) 0xd6, (byte) 0x64, - (byte) 0xef, (byte) 0x2c, (byte) 0x89, (byte) 0xc7, (byte) 0x39, - (byte) 0x75, (byte) 0x87, (byte) 0x82, (byte) 0x61, (byte) 0xbe, - (byte) 0xd1, (byte) 0xcd, (byte) 0x70, (byte) 0x41, (byte) 0x85, - (byte) 0x99, (byte) 0x55, (byte) 0x75, (byte) 0x6f, (byte) 0x16, - (byte) 0xc0, (byte) 0x40, (byte) 0xf1, (byte) 0x0c, (byte) 0x78, - (byte) 0x1f, (byte) 0xe8, (byte) 0x63, (byte) 0x5d, (byte) 0xfa, - (byte) 0x37, (byte) 0xc1, (byte) 0xce, (byte) 0x97, (byte) 0x76, - (byte) 0xa5, (byte) 0x48, (byte) 0x5b, (byte) 0x88, (byte) 0xe4, - (byte) 0xd5, (byte) 0xb8, (byte) 0x06, (byte) 0xf5, (byte) 0x7f, - (byte) 0x92, (byte) 0xda, (byte) 0x99, (byte) 0xa5, (byte) 0x5a, - (byte) 0x64, (byte) 0xc9, (byte) 0x30, (byte) 0x2c, (byte) 0x77, - (byte) 0x58, (byte) 0x60, (byte) 0xa6, (byte) 0x35, (byte) 0x1d, - (byte) 0x71, (byte) 0xfb, (byte) 0x49, (byte) 0x24, (byte) 0x6c, - (byte) 0x34, (byte) 0x29, (byte) 0xa0, (byte) 0x47, (byte) 0xf1, - (byte) 0x14, (byte) 0xad, (byte) 0xc2, (byte) 0x85, (byte) 0x41, - (byte) 0xdd, (byte) 0x2c, (byte) 0x78, (byte) 0x2a, (byte) 0x5a, - (byte) 0x24, (byte) 0x7f, (byte) 0x19, (byte) 0xf4, (byte) 0x0a, - (byte) 0x2e, (byte) 0x1d, (byte) 0x92, (byte) 0x80, (byte) 0xe5, - (byte) 0xe4, (byte) 0x05, (byte) 0x28, (byte) 0x48, (byte) 0x5c, - (byte) 0x34, (byte) 0xc8, (byte) 0x22 }; - - /** - * Valid DH parameters encoding - */ - private static byte[] dhParamsEncoded = { (byte) 0x30, (byte) 0x82, - (byte) 0x01, (byte) 0x0b, (byte) 0x02, (byte) 0x81, (byte) 0x81, - (byte) 0x00, (byte) 0xce, (byte) 0x2c, (byte) 0x4f, (byte) 0xea, - (byte) 0xf2, (byte) 0x83, (byte) 0xc5, (byte) 0x38, (byte) 0xc9, - (byte) 0xb6, (byte) 0xd4, (byte) 0xf8, (byte) 0xb8, (byte) 0x17, - (byte) 0xa1, (byte) 0x7d, (byte) 0x4c, (byte) 0xec, (byte) 0x6b, - (byte) 0xd7, (byte) 0xc2, (byte) 0x1a, (byte) 0x35, (byte) 0x85, - (byte) 0x54, (byte) 0x14, (byte) 0x6c, (byte) 0x52, (byte) 0x24, - (byte) 0xbf, (byte) 0xe6, (byte) 0x32, (byte) 0xd8, (byte) 0x42, - (byte) 0xac, (byte) 0xb3, (byte) 0x28, (byte) 0x4f, (byte) 0x77, - (byte) 0xf6, (byte) 0xfc, (byte) 0xea, (byte) 0xea, (byte) 0x72, - (byte) 0xcf, (byte) 0x1d, (byte) 0x7b, (byte) 0xe1, (byte) 0x72, - (byte) 0xfa, (byte) 0x77, (byte) 0x12, (byte) 0xa9, (byte) 0x42, - (byte) 0xba, (byte) 0xc4, (byte) 0xf4, (byte) 0xfb, (byte) 0xbd, - (byte) 0x9f, (byte) 0x63, (byte) 0x9a, (byte) 0x58, (byte) 0x6b, - (byte) 0xb6, (byte) 0xa2, (byte) 0x6e, (byte) 0x3a, (byte) 0x71, - (byte) 0xf3, (byte) 0x43, (byte) 0x5e, (byte) 0x6f, (byte) 0x8a, - (byte) 0xd0, (byte) 0xac, (byte) 0xe5, (byte) 0x60, (byte) 0x76, - (byte) 0x57, (byte) 0x1f, (byte) 0x83, (byte) 0x4d, (byte) 0xbc, - (byte) 0xaa, (byte) 0xb1, (byte) 0x18, (byte) 0x40, (byte) 0x19, - (byte) 0xac, (byte) 0x31, (byte) 0xd4, (byte) 0xfc, (byte) 0x39, - (byte) 0x01, (byte) 0x46, (byte) 0xab, (byte) 0xab, (byte) 0x53, - (byte) 0x19, (byte) 0x2d, (byte) 0xf8, (byte) 0x4c, (byte) 0xd3, - (byte) 0x9f, (byte) 0x4d, (byte) 0xa6, (byte) 0x71, (byte) 0x92, - (byte) 0x06, (byte) 0xc7, (byte) 0x89, (byte) 0x70, (byte) 0xc4, - (byte) 0xc6, (byte) 0xa2, (byte) 0x1f, (byte) 0x05, (byte) 0x4a, - (byte) 0x5b, (byte) 0x84, (byte) 0xf9, (byte) 0xfb, (byte) 0x98, - (byte) 0x63, (byte) 0xc9, (byte) 0x9c, (byte) 0x13, (byte) 0x02, - (byte) 0x81, (byte) 0x80, (byte) 0x36, (byte) 0x55, (byte) 0x93, - (byte) 0xb3, (byte) 0x22, (byte) 0x0c, (byte) 0xcd, (byte) 0x7c, - (byte) 0xc3, (byte) 0xe3, (byte) 0xa3, (byte) 0x8a, (byte) 0xd7, - (byte) 0xb4, (byte) 0xe9, (byte) 0xe0, (byte) 0xfa, (byte) 0xa9, - (byte) 0xa8, (byte) 0x69, (byte) 0xd6, (byte) 0xa6, (byte) 0x20, - (byte) 0xb8, (byte) 0xd4, (byte) 0xe7, (byte) 0x87, (byte) 0x4e, - (byte) 0xf3, (byte) 0x90, (byte) 0x10, (byte) 0xdd, (byte) 0x75, - (byte) 0x5d, (byte) 0xff, (byte) 0xee, (byte) 0xf0, (byte) 0xef, - (byte) 0x6a, (byte) 0x0a, (byte) 0xb0, (byte) 0xf1, (byte) 0x8a, - (byte) 0xb6, (byte) 0x7b, (byte) 0x39, (byte) 0x95, (byte) 0xd5, - (byte) 0x24, (byte) 0x83, (byte) 0x10, (byte) 0x95, (byte) 0x34, - (byte) 0x08, (byte) 0x77, (byte) 0x1d, (byte) 0xaf, (byte) 0x69, - (byte) 0xf0, (byte) 0xb5, (byte) 0xdb, (byte) 0x24, (byte) 0x89, - (byte) 0x72, (byte) 0xb2, (byte) 0x0d, (byte) 0x57, (byte) 0x94, - (byte) 0xb0, (byte) 0xe8, (byte) 0xc2, (byte) 0x37, (byte) 0x45, - (byte) 0x5a, (byte) 0xfc, (byte) 0xa1, (byte) 0xa0, (byte) 0x41, - (byte) 0xe4, (byte) 0x0c, (byte) 0xa3, (byte) 0x40, (byte) 0x8b, - (byte) 0x9c, (byte) 0x19, (byte) 0x63, (byte) 0x61, (byte) 0xd9, - (byte) 0x05, (byte) 0xbf, (byte) 0xc5, (byte) 0xe8, (byte) 0xf7, - (byte) 0xbd, (byte) 0x3a, (byte) 0xf5, (byte) 0x78, (byte) 0xc2, - (byte) 0x92, (byte) 0xe8, (byte) 0x60, (byte) 0x07, (byte) 0x3e, - (byte) 0x57, (byte) 0x12, (byte) 0xf6, (byte) 0x97, (byte) 0x1f, - (byte) 0xea, (byte) 0x02, (byte) 0xa3, (byte) 0x19, (byte) 0xa7, - (byte) 0x5a, (byte) 0x9b, (byte) 0xf6, (byte) 0xd2, (byte) 0x0f, - (byte) 0xe9, (byte) 0x6b, (byte) 0xeb, (byte) 0xd7, (byte) 0x93, - (byte) 0x9a, (byte) 0x7e, (byte) 0x4f, (byte) 0xd6, (byte) 0x29, - (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0xff }; - - /** - * pretends to be encrypted private key - */ - private static final byte[] encryptedData; private static final Provider[] provider; - private static final HashMap validEPKIEncodings = new HashMap(); - private static final HashMap validEPKIEncodingsNP = new HashMap(); - private static final HashMap validAPEncodings = new HashMap(); static { - validEPKIEncodings.put("DH", dhEncryptedPrivateKeyInfo); - validEPKIEncodings.put("DIFFIEHELLMAN", dhEncryptedPrivateKeyInfo); - validEPKIEncodings.put("DIFFIE-HELLMAN", dhEncryptedPrivateKeyInfo); - validEPKIEncodings.put("1.2.840.113549.1.3.1", - dhEncryptedPrivateKeyInfo); - validEPKIEncodingsNP.put("DH", dhEncryptedPrivateKeyInfoNP); - validEPKIEncodingsNP.put("DIFFIEHELLMAN", dhEncryptedPrivateKeyInfoNP); - validEPKIEncodingsNP.put("DIFFIE-HELLMAN", dhEncryptedPrivateKeyInfoNP); - validEPKIEncodings.put("DSA", dsaEncryptedPrivateKeyInfo); - validEPKIEncodings.put("1.2.840.10040.4.1", dsaEncryptedPrivateKeyInfo); - validEPKIEncodingsNP.put("DIFFIE-HELLMAN", dhEncryptedPrivateKeyInfoNP); - validEPKIEncodingsNP.put("DSA", dsaEncryptedPrivateKeyInfoNP); - validAPEncodings.put("DH", dhParamsEncoded); - validAPEncodings.put("DIFFIEHELLMAN", dhParamsEncoded); - validAPEncodings.put("DIFFIE-HELLMAN", dhParamsEncoded); - validAPEncodings.put("1.2.840.113549.1.3.1", dhParamsEncoded); - validAPEncodings.put("DSA", dsaParamsEncoded); - validAPEncodings.put("1.2.840.10040.4.1", dsaParamsEncoded); - - encryptedData = new byte[1024]; - for (int i = 0; i < encryptedData.length; i++) { - encryptedData[i] = (byte) i; - } provider = Security.getProviders(); } /** - * Algorithm_names/standard_names to be used in tests - * "DSA" and "DH" must be always presented + * Algorithm names/transformations used in roundtrip tests of + * getKeySpec(...) methods */ - private final static String[][] algName0 = new String[][] { - {"DSA", "DSA" }, - {"DH", "DiffieHellman" }, - {"1.2.840.10040.4.1", "DSA"}, - {"1.2.840.113549.1.1.1", "RSA"}, - {"1.2.840.113549.1.3.1", "DiffieHellman"}, - {"1.2.840.113549.1.5.3", "pbeWithMD5AndDES-CBC"}, - {"1.2.840.113549.1.12.1.3", "pbeWithSHAAnd3-KeyTripleDES-CBC"}, -// {"1.2.840.113549.1.12.1.6", "pbeWithSHAAnd40BitRC2-CBC"}, - {"1.2.840.113549.3.2", "RC2-CBC"}, - {"1.2.840.113549.3.3", "RC2-EBC"}, - {"1.2.840.113549.3.4", "RC4"}, - {"1.2.840.113549.3.5", "RC4WithMAC"}, - {"1.2.840.113549.3.6", "DESx-CBC"}, - {"1.2.840.113549.3.7", "TripleDES-CBC"}, - {"1.2.840.113549.3.8", "rc5CBC"}, - {"1.2.840.113549.3.9", "RC5-CBC"}, - {"1.2.840.113549.3.10", "DESCDMF"}, - }; - - /** - * Algorithm names/transformations used in roundtrip tests - * of getKeySpec(...) methods - */ private static final String[][] algName = { - // AES - {"AES", null}, -// {"AES", "AES/ECB/PKCS5Padding"}, -// {"AES", "AES/CBC/PKCS5Padding"}, -// {"AES", "AES/OFB/PKCS5Padding"}, -// {"AES", "AES/CFB/PKCS5Padding"}, -// {"2.16.840.1.101.3.4.1.1", null}, -// {"2.16.840.1.101.3.4.1.2", null}, -// {"2.16.840.1.101.3.4.1.3", null}, -// {"2.16.840.1.101.3.4.1.4", null}, -// {"2.16.840.1.101.3.4.1.5", null}, -// {"2.16.840.1.101.3.4.1.21", null}, -// {"2.16.840.1.101.3.4.1.22", null}, -// {"2.16.840.1.101.3.4.1.23", null}, -// {"2.16.840.1.101.3.4.1.24", null}, -// {"2.16.840.1.101.3.4.1.25", null}, -// {"2.16.840.1.101.3.4.1.41", null}, -// {"2.16.840.1.101.3.4.1.42", null}, -// {"2.16.840.1.101.3.4.1.43", null}, -// {"2.16.840.1.101.3.4.1.44", null}, -// {"2.16.840.1.101.3.4.1.45", null}, + // AES + { "AES", null }, + // {"AES", "AES/ECB/PKCS5Padding"}, + // {"AES", "AES/CBC/PKCS5Padding"}, + // {"AES", "AES/OFB/PKCS5Padding"}, + // {"AES", "AES/CFB/PKCS5Padding"}, + // {"2.16.840.1.101.3.4.1.1", null}, + // {"2.16.840.1.101.3.4.1.2", null}, + // {"2.16.840.1.101.3.4.1.3", null}, + // {"2.16.840.1.101.3.4.1.4", null}, + // {"2.16.840.1.101.3.4.1.5", null}, + // {"2.16.840.1.101.3.4.1.21", null}, + // {"2.16.840.1.101.3.4.1.22", null}, + // {"2.16.840.1.101.3.4.1.23", null}, + // {"2.16.840.1.101.3.4.1.24", null}, + // {"2.16.840.1.101.3.4.1.25", null}, + // {"2.16.840.1.101.3.4.1.41", null}, + // {"2.16.840.1.101.3.4.1.42", null}, + // {"2.16.840.1.101.3.4.1.43", null}, + // {"2.16.840.1.101.3.4.1.44", null}, + // {"2.16.840.1.101.3.4.1.45", null}, // Blowfish // NO OIDs for Blowfish defined (?) - {"Blowfish",null}, -// {"Blowfish","Blowfish/CBC/PKCS5Padding"}, -// {"Blowfish","Blowfish/CFB/PKCS5Padding"}, -// {"Blowfish","Blowfish/OFB/PKCS5Padding"}, -// {"Blowfish","Blowfish/PCBC/PKCS5Padding"}, + { "Blowfish", null }, + // {"Blowfish","Blowfish/CBC/PKCS5Padding"}, + // {"Blowfish","Blowfish/CFB/PKCS5Padding"}, + // {"Blowfish","Blowfish/OFB/PKCS5Padding"}, + // {"Blowfish","Blowfish/PCBC/PKCS5Padding"}, // DES: OIW OIDs only - // {iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) desECB(6)} + // {iso(1) identified-organization(3) oiw(14) secsig(3) + // algorithms(2) desECB(6)} // 1.3.14.3.2.6 // 1.3.14.3.2.7 // 1.3.14.3.2.8 // 1.3.14.3.2.9 - {"DES",null}, -// {"DES", "DES/CBC/PKCS5Padding"}, -// {"DES","DES/CFB/PKCS5Padding"}, -// {"DES","DES/OFB/PKCS5Padding"}, -// {"DES","DES/PCBC/PKCS5Padding"}, + { "DES", null }, + // {"DES", "DES/CBC/PKCS5Padding"}, + // {"DES","DES/CFB/PKCS5Padding"}, + // {"DES","DES/OFB/PKCS5Padding"}, + // {"DES","DES/PCBC/PKCS5Padding"}, // DESede (=TripleDes) - //{iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) desEDE(17)} + //{iso(1) identified-organization(3) oiw(14) secsig(3) + // algorithms(2) desEDE(17)} // 1.3.14.3.2.17 -// {"DESede",null}, -// {"DESede","DESede/CBC/PKCS5Padding"}, -// {"DESede","DESede/CFB/PKCS5Padding"}, -// {"DESede","DESede/OFB/PKCS5Padding"}, -// {"DESede","DESede/PCBC/PKCS5Padding"}, - {"TripleDES",null}, -// {"TripleDES","TripleDES/CBC/PKCS5Padding"}, -// {"TripleDES","TripleDES/CFB/PKCS5Padding"}, -// {"TripleDES","TripleDES/OFB/PKCS5Padding"}, -// {"TripleDES","TripleDES/PCBC/PKCS5Padding"}, + // {"DESede",null}, + // {"DESede","DESede/CBC/PKCS5Padding"}, + // {"DESede","DESede/CFB/PKCS5Padding"}, + // {"DESede","DESede/OFB/PKCS5Padding"}, + // {"DESede","DESede/PCBC/PKCS5Padding"}, + { "TripleDES", null }, + // {"TripleDES","TripleDES/CBC/PKCS5Padding"}, + // {"TripleDES","TripleDES/CFB/PKCS5Padding"}, + // {"TripleDES","TripleDES/OFB/PKCS5Padding"}, + // {"TripleDES","TripleDES/PCBC/PKCS5Padding"}, // PBEWithAnd - {"PBEWithMD5AndTripleDES",null}, - // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-5(5) pbeWithMD5AndDES-CBC(3)} - {"PBEWithMD5AndDES","PBEWithMD5AndDES/CBC/PKCS5Padding"}, - {"PBEWithMD5AndDES",null}, - {"PBEWithHmacSHA1AndDESede",null}, + { "PBEWithMD5AndTripleDES", null }, + // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-5(5) + // pbeWithMD5AndDES-CBC(3)} + { "PBEWithMD5AndDES", "PBEWithMD5AndDES/CBC/PKCS5Padding" }, + { "PBEWithMD5AndDES", null }, { "PBEWithHmacSHA1AndDESede", null }, // more oids: - // {iso(1) member-body(2) us(840) nortelnetworks(113533) entrust(7) algorithms(66) pbeWithMD5AndCAST5-CBC(12)} + // {iso(1) member-body(2) us(840) nortelnetworks(113533) entrust(7) + // algorithms(66) pbeWithMD5AndCAST5-CBC(12)} // // also named pbeWithSHAAnd128BitRC4, pbeWithSHA1And128BitRC4: - // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-12(12) pkcs-12-PbeIds(1) pkcs-12-OfflineTransportMode(1)} + // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-12(12) + // pkcs-12-PbeIds(1) pkcs-12-OfflineTransportMode(1)} // - // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-12(12) pkcs-12-PbeIds(1)} + - // pbeWithSHAAnd40BitRC4(2) pbeWithSHAAnd3-KeyTripleDES-CBC(3) pbeWithSHAAnd2-KeyTripleDES-CBC(4) pbeWithSHAAnd128BitRC2-CBC(5) pbeWithSHAAnd40BitRC2-CBC(6) + // {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-12(12) + // pkcs-12-PbeIds(1)} + + // pbeWithSHAAnd40BitRC4(2) pbeWithSHAAnd3-KeyTripleDES-CBC(3) + // pbeWithSHAAnd2-KeyTripleDES-CBC(4) pbeWithSHAAnd128BitRC2-CBC(5) + // pbeWithSHAAnd40BitRC2-CBC(6) // DiffieHellman - {"DiffieHellman",null}, // 1.2.840.10046.2.1 -// {"DH",null}, // 1.2.840.10046.2.1 -// {"1.2.840.113549.1.3.1", null}, + { "DiffieHellman", null }, // 1.2.840.10046.2.1 + // {"DH",null}, // 1.2.840.10046.2.1 + // {"1.2.840.113549.1.3.1", null}, - {"DSA",null}, // 1.2.840.10040.4.1 + { "DSA", null }, // 1.2.840.10040.4.1 - {"RC2",null}, + { "RC2", null }, - {"RC4",null}, + { "RC4", null }, - {"RC5",null}, + { "RC5", null }, -// {"1.2.840.113549.1.12.1.1",null}, -// {"1.2.840.113549.1.12.1.2",null}, - {"1.2.840.113549.1.12.1.3",null}, - {"PBEWithSHA1AndDESede",null}, -// {"1.2.840.113549.1.12.1.4",null}, -// {"1.2.840.113549.1.12.1.5",null}, -// {"1.2.840.113549.1.12.1.6",null}, -// {"ELGAMAL/PKCS1", "ELGAMAL/ECB/PKCS1PADDING"}, -// {"ELGAMAL/PKCS1","ELGAMAL/NONE/PKCS1PADDING"}, -// {"PBEWITHSHAAND3-KEYTRIPLEDES-CBC", null}, -// {"PBEWITHSHA1ANDDESEDE", null}, -// {"PBEWithSHAAnd3KeyTripleDES",null}, -// {"PBEWITHSHAAND3-KEYTRIPLEDES-CBC",null}, -// -// {"RC5-32",null}, -// -// {"RSA/1", "RSA/1/PKCS1PADDING"}, -// {"RSA/2", "RSA/2/PKCS1PADDING"}, -// {"RSA/ISO9796-1", "RSA/ECB/ISO9796-1PADDING"}, -// {"RSA", "RSA/ECB/NOPADDING"}, -// {"RSA/OAEP", "RSA/ECB/OAEPPADDING"}, -// {"RSA/PKCS1", "RSA/ECB/PKCS1PADDING"}, -// {"RSA/ISO9796-1", "RSA/NONE/ISO9796-1PADDING"}, -// {"RSA", "RSA/NONE/NOPADDING"}, -// {"RSA/OAEP", "RSA/NONE/OAEPPADDING"}, -// {"RSA/PKCS1", "RSA/NONE/PKCS1PADDING"}, -// {"RSA",null}, // 1.2.840.113549.1.1.1 -// {"1.2.840.113549.1.1.1", null}, - }; - - /** - * Constructor for EncryptedPrivateKeyInfoTest. - * - * @param arg0 - */ - public EncryptedPrivateKeyInfoTest(String arg0) { - super(arg0); - } - + // {"1.2.840.113549.1.12.1.1",null}, + // {"1.2.840.113549.1.12.1.2",null}, + { "1.2.840.113549.1.12.1.3", null }, + { "PBEWithSHA1AndDESede", null }, + // {"1.2.840.113549.1.12.1.4",null}, + // {"1.2.840.113549.1.12.1.5",null}, + // {"1.2.840.113549.1.12.1.6",null}, + // {"ELGAMAL/PKCS1", "ELGAMAL/ECB/PKCS1PADDING"}, + // {"ELGAMAL/PKCS1","ELGAMAL/NONE/PKCS1PADDING"}, + // {"PBEWITHSHAAND3-KEYTRIPLEDES-CBC", null}, + // {"PBEWITHSHA1ANDDESEDE", null}, + // {"PBEWithSHAAnd3KeyTripleDES",null}, + // {"PBEWITHSHAAND3-KEYTRIPLEDES-CBC",null}, // - // Tests + // {"RC5-32",null}, // + // {"RSA/1", "RSA/1/PKCS1PADDING"}, + // {"RSA/2", "RSA/2/PKCS1PADDING"}, + // {"RSA/ISO9796-1", "RSA/ECB/ISO9796-1PADDING"}, + // {"RSA", "RSA/ECB/NOPADDING"}, + // {"RSA/OAEP", "RSA/ECB/OAEPPADDING"}, + // {"RSA/PKCS1", "RSA/ECB/PKCS1PADDING"}, + // {"RSA/ISO9796-1", "RSA/NONE/ISO9796-1PADDING"}, + // {"RSA", "RSA/NONE/NOPADDING"}, + // {"RSA/OAEP", "RSA/NONE/OAEPPADDING"}, + // {"RSA/PKCS1", "RSA/NONE/PKCS1PADDING"}, + // {"RSA",null}, // 1.2.840.113549.1.1.1 + // {"1.2.840.113549.1.1.1", null}, + }; /** * Test #1 for EncryptedPrivateKeyInfo(byte[]) constructor @@ -1351,12 +197,13 @@ * Assertion: creates EncryptedPrivateKeyInfo instance
* Test preconditions: valid parameters passed
* Expected: must pass without any exceptions + * * @throws IOException * @throws NoSuchAlgorithmException */ public final void testEncryptedPrivateKeyInfobyteArray1() throws Exception { - new EncryptedPrivateKeyInfo(getValidEncryptedPrivateKeyInfoEncoding("DH")); - + new EncryptedPrivateKeyInfo(EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding("DH")); } /** @@ -1402,8 +249,8 @@ */ public final void testEncryptedPrivateKeyInfobyteArray4() { try { - new EncryptedPrivateKeyInfo( - new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + new EncryptedPrivateKeyInfo(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10 }); fail(getName() + ": IOException has not been thrown"); } catch (IOException ok) { } @@ -1420,7 +267,8 @@ byte[] enc = null; try { // 1: get valid encoding - enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); + enc = EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding("DSA"); // ... and corrupt it (set wrong alg OID length) enc[9] = (byte) 6; @@ -1432,7 +280,8 @@ try { // 2: get valid encoding - enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); + enc = EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding("DSA"); // ... and corrupt it (set wrong encrypted data tag) enc[307] = (byte) 6; new EncryptedPrivateKeyInfo(enc); @@ -1442,7 +291,8 @@ try { // 3: get valid encoding - enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); + enc = EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding("DSA"); // ... and corrupt it (set wrong encrypted data length) enc[310] = (byte) 1; new EncryptedPrivateKeyInfo(enc); @@ -1452,7 +302,8 @@ try { // 4: get valid encoding - enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); + enc = EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding("DSA"); // ... and corrupt it (set wrong tag for alg params sequence) enc[17] = (byte) 0x29; EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc); @@ -1472,7 +323,8 @@ try { // 5: get valid encoding - enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); + enc = EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding("DSA"); // ... and corrupt it (set wrong length for alg params sequence) enc[20] = (byte) 0x1d; new EncryptedPrivateKeyInfo(enc); @@ -1482,7 +334,8 @@ try { // 6: get valid encoding - enc = getValidEncryptedPrivateKeyInfoEncoding("DSA"); + enc = EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding("DSA"); // ... and corrupt it (set wrong length for alg params sequence) enc[20] = (byte) 0x1f; new EncryptedPrivateKeyInfo(enc); @@ -1502,11 +355,11 @@ * @throws IOException */ public final void testEncryptedPrivateKeyInfobyteArray6() throws Exception { - byte[] encoded = getValidEncryptedPrivateKeyInfoEncoding("DSA"); + byte[] encoded = EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding("DSA"); byte[] encodedCopy = encoded.clone(); // pass valid array - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - encodedCopy); + EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(encodedCopy); // modify array passed encodedCopy[9] = (byte) 6; // check that internal state has not been affected @@ -1523,10 +376,11 @@ public final void testEncryptedPrivateKeyInfoStringbyteArray1() { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { new EncryptedPrivateKeyInfo( - algName0[i][0], encryptedData); + EncryptedPrivateKeyInfoData.algName0[i][0], + EncryptedPrivateKeyInfoData.encryptedData); performed = true; } catch (NoSuchAlgorithmException allowed) { } @@ -1545,13 +399,15 @@ */ public final void testEncryptedPrivateKeyInfoStringbyteArray2() { try { - new EncryptedPrivateKeyInfo("bla-bla", encryptedData); + new EncryptedPrivateKeyInfo("bla-bla", + EncryptedPrivateKeyInfoData.encryptedData); fail(getName() + ": NoSuchAlgorithmException has not been thrown"); } catch (NoSuchAlgorithmException ok) { } try { - new EncryptedPrivateKeyInfo("", encryptedData); + new EncryptedPrivateKeyInfo("", + EncryptedPrivateKeyInfoData.encryptedData); fail(getName() + ": NoSuchAlgorithmException has not been thrown"); } catch (NoSuchAlgorithmException ok) { } @@ -1572,7 +428,8 @@ throws NoSuchAlgorithmException { // pass null as name try { - new EncryptedPrivateKeyInfo((String) null, encryptedData); + new EncryptedPrivateKeyInfo((String) null, + EncryptedPrivateKeyInfoData.encryptedData); fail(getName() + ": NullPointerException has not been thrown"); } catch (NullPointerException ok) { } @@ -1582,8 +439,6 @@ new EncryptedPrivateKeyInfo("DSA", null); fail(getName() + ": NullPointerException has not been thrown"); } catch (NullPointerException ok) { - } catch (NoSuchAlgorithmException allowedFailure) { - fail(getName() + ": " + allowedFailure); } } @@ -1595,14 +450,12 @@ * Test preconditions: pass empty encrypted data
* Expected: IllegalArgumentException */ - public final void testEncryptedPrivateKeyInfoStringbyteArray4() { + public final void testEncryptedPrivateKeyInfoStringbyteArray4() + throws Exception { try { - new EncryptedPrivateKeyInfo("DSA", - new byte[] {}); + new EncryptedPrivateKeyInfo("DSA", new byte[] {}); fail(getName() + ": IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - } catch (NoSuchAlgorithmException allowedFailure) { - fail(getName() + " " + allowedFailure); } } @@ -1616,19 +469,18 @@ * * @throws IOException */ - public final void testEncryptedPrivateKeyInfoStringbyteArray5() { - try { - byte[] encryptedDataCopy = encryptedData.clone(); - // pass valid array - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo("DSA", - encryptedDataCopy); - // modify array passed - encryptedDataCopy[0] = (byte) 6; - // check that internal state has not been affected - assertTrue(Arrays.equals(encryptedData, epki.getEncryptedData())); - } catch (NoSuchAlgorithmException allowedFailure) { - fail(getName() + " " + allowedFailure); - } + public final void testEncryptedPrivateKeyInfoStringbyteArray5() + throws Exception { + byte[] encryptedDataCopy = EncryptedPrivateKeyInfoData.encryptedData + .clone(); + // pass valid array + EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo("DSA", + encryptedDataCopy); + // modify array passed + encryptedDataCopy[0] = (byte) 6; + // check that internal state has not been affected + assertTrue(Arrays.equals(EncryptedPrivateKeyInfoData.encryptedData, + epki.getEncryptedData())); } /** @@ -1645,15 +497,17 @@ public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray1() throws IOException { - boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + boolean performed = false; + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { AlgorithmParameters ap = AlgorithmParameters - .getInstance(algName0[i][0]); + .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]); // use pregenerated AlgorithmParameters encodings - ap.init(getParametersEncoding(algName0[i][0])); + ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0])); - new EncryptedPrivateKeyInfo(ap, encryptedData); + new EncryptedPrivateKeyInfo(ap, + EncryptedPrivateKeyInfoData.encryptedData); performed = true; } catch (NoSuchAlgorithmException allowedFailure) { @@ -1680,7 +534,8 @@ throws NoSuchAlgorithmException, IOException { // 1: pass null as AlgorithmParameters try { - new EncryptedPrivateKeyInfo((AlgorithmParameters) null, encryptedData); + new EncryptedPrivateKeyInfo((AlgorithmParameters) null, + EncryptedPrivateKeyInfoData.encryptedData); fail(getName() + ": NullPointerException has not been thrown"); } catch (NullPointerException ok) { } @@ -1689,12 +544,10 @@ try { AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA"); // use pregenerated AlgorithmParameters encodings - ap.init(getParametersEncoding("DSA")); + ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA")); new EncryptedPrivateKeyInfo(ap, null); fail(getName() + ": NullPointerException has not been thrown"); } catch (NullPointerException ok) { - } catch (NoSuchAlgorithmException allowedFailure) { - fail(getName() + " " + allowedFailure); } } @@ -1712,18 +565,16 @@ * @throws IOException */ public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray3() - throws IOException { + throws Exception { try { AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA"); // use pregenerated AlgorithmParameters encodings - ap.init(getParametersEncoding("DSA")); + ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA")); new EncryptedPrivateKeyInfo(ap, new byte[] {}); fail(getName() + ": IllegalArgumentException has not been thrown"); } catch (IllegalArgumentException ok) { - } catch (NoSuchAlgorithmException allowedFailure) { - fail(getName() + " " + allowedFailure); } } @@ -1740,118 +591,25 @@ * @throws IOException */ public final void testEncryptedPrivateKeyInfoAlgorithmParametersbyteArray4() - throws IOException { - try { - AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA"); - // use pregenerated AlgorithmParameters encodings - ap.init(getParametersEncoding("DSA")); + throws Exception { + AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA"); + // use pregenerated AlgorithmParameters encodings + ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding("DSA")); - byte[] encryptedDataCopy = encryptedData.clone(); - // pass valid array - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - encryptedDataCopy); + byte[] encryptedDataCopy = EncryptedPrivateKeyInfoData.encryptedData.clone(); + // pass valid array + EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, + encryptedDataCopy); - // modify array passed - encryptedDataCopy[0] = (byte) 6; + // modify array passed + encryptedDataCopy[0] = (byte) 6; - // check that internal state has not been affected - assertTrue(Arrays.equals(encryptedData, epki.getEncryptedData())); - - } catch (NoSuchAlgorithmException allowedFailure) { - fail(getName() + " " + allowedFailure); - } + // check that internal state has not been affected + assertTrue(Arrays.equals(EncryptedPrivateKeyInfoData.encryptedData, + epki.getEncryptedData())); } /** - * Test #1 for getAlgName() method
- * Assertion: Returns the encryption algorithm name
- * Test preconditions: test object created using ctor which takes encoded - * form as the only parameter
- * Expected: corresponding algorithm name must be returned - * - * @throws IOException - */ - public final void testGetAlgName01() throws IOException { - boolean performed = false; - for (int i = 0; i < algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - getValidEncryptedPrivateKeyInfoEncoding(algName0[i][0])); - -// logln(getName() + ": " + algName0[i][0] + -// ", expected: " + algName0[i][1] + -// ", got: " + epki.getAlgName()); - assertEquals(algName0[i][1], epki.getAlgName()); - - performed = true; - } catch (NoSuchAlgorithmException allowed) { - } - } - assertTrue("Test not perfrormed", performed); - } - - /** - * Test #2 for getAlgName() method
- * Assertion: Returns the encryption algorithm name
- * Test preconditions: test object created using ctor which takes algorithm - * name and encrypted data as a parameters
- * Expected: corresponding algorithm name must be returned - * - * @throws IOException - */ - public final void testGetAlgName02() { - boolean performed = false; - for (int i = 0; i < algName0.length; i++) { - try { - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - algName0[i][0], encryptedData); - -// logln(getName() + ": " + algName0[i][0] + -// ", expected: " + algName0[i][1] + -// ", got: " + epki.getAlgName()); - assertEquals(algName0[i][1], epki.getAlgName()); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not perfrormed", performed); - } - - /** - * Test #3 for getAlgName() method
- * Assertion: Returns the encryption algorithm name
- * Test preconditions: test object created using ctor which takes - * AlgorithmParameters and encrypted data as a parameters
- * Expected: corresponding algorithm name must be returned - * - * @throws IOException - */ - public final void testGetAlgName03() throws IOException { - boolean performed = false; - for (int i = 0; i < algName0.length; i++) { - try { - AlgorithmParameters ap = AlgorithmParameters - .getInstance(algName0[i][0]); - // use pregenerated AlgorithmParameters encodings - ap.init(getParametersEncoding(algName0[i][0])); - - EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - encryptedData); - -// logln(getName() + ": " + algName0[i][0] + -// ", expected: " + algName0[i][1] + -// ", got: " + epki.getAlgName()); - assertEquals(algName0[i][1], epki.getAlgName()); - - performed = true; - } catch (NoSuchAlgorithmException allowedFailure) { - } - } - assertTrue("Test not perfrormed", performed); - } - - /** * Test #1 for getAlgParameters() method
* Assertion: returns the algorithm parameters
* Test preconditions: test object created using ctor which takes encoded @@ -1863,10 +621,12 @@ */ public final void testGetAlgParameters01() throws IOException { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - getValidEncryptedPrivateKeyInfoEncoding(algName0[i][0])); + EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0])); AlgorithmParameters apar = epki.getAlgParameters(); if (apar == null) { @@ -1875,8 +635,11 @@ // check that method under test returns // parameters with the same encoded form - assertTrue(Arrays.equals(getParametersEncoding(algName0[i][0]), - apar.getEncoded())); + assertTrue(Arrays + .equals( + EncryptedPrivateKeyInfoData + .getParametersEncoding(EncryptedPrivateKeyInfoData.algName0[i][0]), + apar.getEncoded())); performed = true; } catch (NoSuchAlgorithmException allowedFailure) { } @@ -1884,20 +647,15 @@ assertTrue("Test not perfrormed", performed); } - public final void testGetAlgParameters01_01() throws IOException { - try { - byte[] validEncodingWithUnknownAlgOID = - getValidEncryptedPrivateKeyInfoEncoding("DH"); - // correct oid value - validEncodingWithUnknownAlgOID[18] = 0; - EncryptedPrivateKeyInfo epki = - new EncryptedPrivateKeyInfo(validEncodingWithUnknownAlgOID); - - assertNull(epki.getAlgParameters()); - - } catch (NoSuchAlgorithmException allowedFailure) { - fail(getName() + " " + allowedFailure); - } + public final void testGetAlgParameters01_01() throws Exception { + byte[] validEncodingWithUnknownAlgOID = EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding("DH"); + // correct oid value + validEncodingWithUnknownAlgOID[18] = 0; + EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( + validEncodingWithUnknownAlgOID); + + assertNull(epki.getAlgParameters()); } /** @@ -1912,11 +670,13 @@ */ public final void testGetAlgParameters02() throws IOException { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - getValidEncryptedPrivateKeyInfoEncoding(algName0[i][0], - false)); + EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0], + false)); // check that method under test returns null assertNull(epki.getAlgParameters()); @@ -1943,10 +703,11 @@ */ public final void testGetAlgParameters03() throws IOException { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - algName0[i][0], encryptedData); + EncryptedPrivateKeyInfoData.algName0[i][0], + EncryptedPrivateKeyInfoData.encryptedData); // check that method under test returns null // for object constructed in such a way @@ -1971,15 +732,18 @@ */ public final void testGetAlgParameters04() throws IOException { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { AlgorithmParameters ap = AlgorithmParameters - .getInstance(algName0[i][0]); + .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]); // use pregenerated AlgorithmParameters encodings - ap.init(getParametersEncoding(algName0[i][0])); + ap + .init(EncryptedPrivateKeyInfoData + .getParametersEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0])); EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - encryptedData); + EncryptedPrivateKeyInfoData.encryptedData); // check that method under test returns // the same parameters instance @@ -2004,15 +768,18 @@ */ public final void testGetEncryptedData01() throws IOException { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - getValidEncryptedPrivateKeyInfoEncoding(algName0[i][0])); + EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0])); // check that method under test returns // valid encrypted data - assertTrue(Arrays - .equals(encryptedData, epki.getEncryptedData())); + assertTrue(Arrays.equals( + EncryptedPrivateKeyInfoData.encryptedData, epki + .getEncryptedData())); performed = true; } catch (NoSuchAlgorithmException allowedFailure) { @@ -2030,15 +797,17 @@ */ public final void testGetEncryptedData02() { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - algName0[i][0], encryptedData); + EncryptedPrivateKeyInfoData.algName0[i][0], + EncryptedPrivateKeyInfoData.encryptedData); // check that method under test returns // valid encrypted data - assertTrue(Arrays - .equals(encryptedData, epki.getEncryptedData())); + assertTrue(Arrays.equals( + EncryptedPrivateKeyInfoData.encryptedData, epki + .getEncryptedData())); performed = true; } catch (NoSuchAlgorithmException allowedFailure) { @@ -2058,20 +827,22 @@ */ public final void testGetEncryptedData03() throws IOException { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { AlgorithmParameters ap = AlgorithmParameters - .getInstance(algName0[i][0]); + .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]); // use pregenerated AlgorithmParameters encodings - ap.init(getParametersEncoding(algName0[i][0])); + ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0])); EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - encryptedData); + EncryptedPrivateKeyInfoData.encryptedData); // check that method under test returns // valid encrypted data - assertTrue(Arrays - .equals(encryptedData, epki.getEncryptedData())); + assertTrue(Arrays.equals( + EncryptedPrivateKeyInfoData.encryptedData, epki + .getEncryptedData())); performed = true; } catch (NoSuchAlgorithmException allowedFailure) { @@ -2090,17 +861,18 @@ */ public final void testGetEncryptedData04() { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - algName0[i][0], encryptedData); + EncryptedPrivateKeyInfoData.algName0[i][0], + EncryptedPrivateKeyInfoData.encryptedData); // check that method under test returns // new array each time byte[] ecd1 = epki.getEncryptedData(); byte[] ecd2 = epki.getEncryptedData(); - assertNotSame(encryptedData, ecd1); - assertNotSame(encryptedData, ecd2); + assertNotSame(EncryptedPrivateKeyInfoData.encryptedData, ecd1); + assertNotSame(EncryptedPrivateKeyInfoData.encryptedData, ecd2); assertNotSame(ecd1, ecd2); performed = true; @@ -2121,9 +893,11 @@ */ public final void testGetEncoded01() throws IOException { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { - byte[] enc = getValidEncryptedPrivateKeyInfoEncoding(algName0[i][0]); + byte[] enc = EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0]); EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(enc); // check that method under test returns @@ -2148,15 +922,18 @@ */ public final void testGetEncoded02() throws IOException { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - algName0[i][0], encryptedData); + EncryptedPrivateKeyInfoData.algName0[i][0], + EncryptedPrivateKeyInfoData.encryptedData); // check that method under test returns // valid encoded form - byte[] refEnc = getValidEncryptedPrivateKeyInfoEncoding( - algName0[i][0], false); + byte[] refEnc = EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0], + false); // System.out.println(Array.toString(refEnc, " ")); byte[] actEnc = epki.getEncoded(); // System.out.println(Array.toString(actEnc, " ")); @@ -2180,21 +957,24 @@ */ public final void testGetEncoded03() throws IOException { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { AlgorithmParameters ap = AlgorithmParameters - .getInstance(algName0[i][0]); + .getInstance(EncryptedPrivateKeyInfoData.algName0[i][0]); // use pregenerated AlgorithmParameters encodings - ap.init(getParametersEncoding(algName0[i][0])); + ap.init(EncryptedPrivateKeyInfoData.getParametersEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0])); EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo(ap, - encryptedData); + EncryptedPrivateKeyInfoData.encryptedData); // check that method under test returns // valid encoded form assertTrue(Arrays.equals( - getValidEncryptedPrivateKeyInfoEncoding(algName0[i][0]), - epki.getEncoded())); + EncryptedPrivateKeyInfoData + .getValidEncryptedPrivateKeyInfoEncoding( + EncryptedPrivateKeyInfoData.algName0[i][0]), + epki.getEncoded())); performed = true; } catch (NoSuchAlgorithmException allowedFailure) { @@ -2215,10 +995,11 @@ */ public final void testGetEncoded04() throws IOException { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - algName0[i][0], encryptedData); + EncryptedPrivateKeyInfoData.algName0[i][0], + EncryptedPrivateKeyInfoData.encryptedData); // check that method under test returns // new array each time @@ -2238,15 +1019,16 @@ public final void testGetKeySpecCipher01() { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - algName0[i][0], encryptedData); + EncryptedPrivateKeyInfoData.algName0[i][0], + EncryptedPrivateKeyInfoData.encryptedData); try { // check that method under test throws NPE - epki.getKeySpec((Cipher)null); + epki.getKeySpec((Cipher) null); fail(getName() + "NullPointerException has not been thrown"); } catch (NullPointerException ok) { @@ -2270,10 +1052,9 @@ for (int i = 0; i < algName.length; i++) { try { // generate test data - TestDataGenerator g = - new TestDataGenerator(algName[i][0], algName[i][1], - privateKeyInfo, null); - + TestDataGenerator g = new TestDataGenerator(algName[i][0], + algName[i][1], privateKeyInfo, null); + // create test object EncryptedPrivateKeyInfo epki; if (g.ap() == null) { @@ -2310,10 +1091,9 @@ for (int i = 0; i < algName.length; i++) { try { // generate test data - TestDataGenerator g = - new TestDataGenerator(algName[i][0], algName[i][1], - privateKeyInfoDamaged, null); - + TestDataGenerator g = new TestDataGenerator(algName[i][0], + algName[i][1], privateKeyInfoDamaged, null); + // create test object EncryptedPrivateKeyInfo epki; if (g.ap() == null) { @@ -2342,15 +1122,16 @@ public final void testGetKeySpecKey01() { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - algName0[i][0], encryptedData); + EncryptedPrivateKeyInfoData.algName0[i][0], + EncryptedPrivateKeyInfoData.encryptedData); try { // check that method under test throws NPE - epki.getKeySpec((Key)null); + epki.getKeySpec((Key) null); fail(getName() + "NullPointerException has not been thrown"); } catch (NullPointerException ok) { @@ -2373,10 +1154,9 @@ for (int i = 0; i < algName.length; i++) { try { // generate test data - TestDataGenerator g = - new TestDataGenerator(algName[i][0], algName[i][1], - privateKeyInfo, null); - + TestDataGenerator g = new TestDataGenerator(algName[i][0], + algName[i][1], privateKeyInfo, null); + // create test object EncryptedPrivateKeyInfo epki; if (g.ap() == null) { @@ -2384,16 +1164,16 @@ } else { epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); } - + try { - PKCS8EncodedKeySpec eks = - epki.getKeySpec(g.pubK()==null ? g.k() : g.pubK()); - + PKCS8EncodedKeySpec eks = epki + .getKeySpec(g.pubK() == null ? g.k() : g.pubK()); + if (!Arrays.equals(privateKeyInfo, eks.getEncoded())) { fail(algName[i][0] + " != " + algName[i][1]); } } catch (InvalidKeyException e) { - fail(algName[i][0] + ", " + algName[i][1] + ": " + e); + fail(algName[i][0] + ", " + algName[i][1] + ": " + e); } performed = true; @@ -2412,10 +1192,9 @@ for (int i = 0; i < algName.length; i++) { try { // generate test data - TestDataGenerator g = - new TestDataGenerator(algName[i][0], algName[i][1], - privateKeyInfoDamaged, null); - + TestDataGenerator g = new TestDataGenerator(algName[i][0], + algName[i][1], privateKeyInfoDamaged, null); + // create test object EncryptedPrivateKeyInfo epki; if (g.ap() == null) { @@ -2423,9 +1202,9 @@ } else { epki = new EncryptedPrivateKeyInfo(g.ap(), g.ct()); } - + try { - epki.getKeySpec(g.pubK()==null ? g.k() : g.pubK()); + epki.getKeySpec(g.pubK() == null ? g.k() : g.pubK()); fail(algName[i][0] + ", " + algName[i][1]); } catch (InvalidKeyException e) { } @@ -2440,15 +1219,16 @@ public final void testGetKeySpecKeyString01() throws Exception { boolean performed = false; - for (int i = 0; i < algName0.length; i++) { + for (int i = 0; i < EncryptedPrivateKeyInfoData.algName0.length; i++) { try { EncryptedPrivateKeyInfo epki = new EncryptedPrivateKeyInfo( - algName0[i][0], encryptedData); + EncryptedPrivateKeyInfoData.algName0[i][0], + EncryptedPrivateKeyInfoData.encryptedData); try { // check that method under test throws NPE - epki.getKeySpec((Key)null, "SomeProviderName"); + epki.getKeySpec((Key) null, "SomeProviderName"); fail(getName() + "NullPointerException has not been thrown"); } catch (NullPointerException ok) { @@ -2457,20 +1237,20 @@ try { // check that method under test throws NPE - epki.getKeySpec( - new Key() { - public String getAlgorithm() { - return "alg"; - } - public String getFormat() { - return "fmt"; - } - public byte[] getEncoded() { - return new byte[] {}; - } - }, - (String)null); + epki.getKeySpec(new Key() { + public String getAlgorithm() { + return "alg"; + } + public String getFormat() { + return "fmt"; + } + + public byte[] getEncoded() { + return new byte[] {}; + } + }, (String) null); + fail(getName() + "NullPointerException has not been thrown"); } catch (NullPointerException ok) { @@ -2488,33 +1268,34 @@ */ public final void test_ROUNDTRIP_GetKeySpecKeyString01() throws Exception { boolean performed = false; - for (int i = 0; i < algName.length; i++) { - for (int l=0; lap if (pbeParamSpec != null) { try { - ap = (provider==null) - ? AlgorithmParameters.getInstance(algName) - : AlgorithmParameters.getInstance(algName, provider); + ap = (provider == null) ? AlgorithmParameters + .getInstance(algName) : AlgorithmParameters + .getInstance(algName, provider); ap.init(pbeParamSpec); pbeParamSpec = null; } catch (NoSuchAlgorithmException e) { @@ -2891,9 +1633,9 @@ } if (ap == null) { - c.init(Cipher.DECRYPT_MODE, pubK==null ? k : pubK); + c.init(Cipher.DECRYPT_MODE, pubK == null ? k : pubK); } else { - c.init(Cipher.DECRYPT_MODE, pubK==null ? k : pubK, ap); + c.init(Cipher.DECRYPT_MODE, pubK == null ? k : pubK, ap); } } catch (InvalidKeyException e) { @@ -2908,346 +1650,284 @@ public Key k() { return k; } + public Key pubK() { return pubK; } + public Cipher c() { return c; } + public byte[] ct() { return ct; } + public AlgorithmParameters ap() { return ap; } } - + // valid PrivateKeyInfo encoding - private static final byte[] privateKeyInfo = { - (byte)0x30,(byte)0x82,(byte)0x02,(byte)0x77, - (byte)0x02,(byte)0x01,(byte)0x00,(byte)0x30, - (byte)0x0d,(byte)0x06,(byte)0x09,(byte)0x2a, - (byte)0x86,(byte)0x48,(byte)0x86,(byte)0xf7, - (byte)0x0d,(byte)0x01,(byte)0x01,(byte)0x01, - (byte)0x05,(byte)0x00,(byte)0x04,(byte)0x82, - (byte)0x02,(byte)0x61,(byte)0x30,(byte)0x82, - (byte)0x02,(byte)0x5d,(byte)0x02,(byte)0x01, - (byte)0x00,(byte)0x02,(byte)0x81,(byte)0x81, - (byte)0x00,(byte)0xb2,(byte)0x4a,(byte)0x9b, - (byte)0x5b,(byte)0xba,(byte)0x01,(byte)0xc0, - (byte)0xcd,(byte)0x65,(byte)0x09,(byte)0x63, - (byte)0x70,(byte)0x0b,(byte)0x5a,(byte)0x1b, - (byte)0x92,(byte)0x08,(byte)0xf8,(byte)0x55, - (byte)0x5e,(byte)0x7c,(byte)0x1b,(byte)0x50, - (byte)0x17,(byte)0xec,(byte)0x44,(byte)0x4c, - (byte)0x58,(byte)0x42,(byte)0x2b,(byte)0x41, - (byte)0x09,(byte)0x59,(byte)0xf2,(byte)0xe1, - (byte)0x5d,(byte)0x43,(byte)0x71,(byte)0x4d, - (byte)0x92,(byte)0x03,(byte)0x1d,(byte)0xb6, - (byte)0x6c,(byte)0x7f,(byte)0x5d,(byte)0x48, - (byte)0xcd,(byte)0x17,(byte)0xec,(byte)0xd7, - (byte)0x4c,(byte)0x39,(byte)0xb1,(byte)0x7b, - (byte)0xe2,(byte)0xbf,(byte)0x96,(byte)0x77, - (byte)0xbe,(byte)0xd0,(byte)0xa0,(byte)0xf0, - (byte)0x2d,(byte)0x6b,(byte)0x24,(byte)0xaa, - (byte)0x14,(byte)0xba,(byte)0x82,(byte)0x79, - (byte)0x10,(byte)0x9b,(byte)0x16,(byte)0x68, - (byte)0x47,(byte)0x81,(byte)0x54,(byte)0xa2, - (byte)0xfa,(byte)0x91,(byte)0x9e,(byte)0x0a, - (byte)0x2a,(byte)0x53,(byte)0xa6,(byte)0xe7, - (byte)0x9e,(byte)0x7d,(byte)0x29,(byte)0x33, - (byte)0xd8,(byte)0x05,(byte)0xfc,(byte)0x02, - (byte)0x3f,(byte)0xbd,(byte)0xc7,(byte)0x6e, - (byte)0xed,(byte)0xaa,(byte)0x30,(byte)0x6c, - (byte)0x5f,(byte)0x52,(byte)0xed,(byte)0x35, - (byte)0x65,(byte)0x4b,(byte)0x0e,(byte)0xc8, - (byte)0xa7,(byte)0x12,(byte)0x10,(byte)0x56, - (byte)0x37,(byte)0xaf,(byte)0x11,(byte)0xfa, - (byte)0x21,(byte)0x0e,(byte)0x99,(byte)0xff, - (byte)0xfa,(byte)0x8c,(byte)0x65,(byte)0x8e, - (byte)0x6d,(byte)0x02,(byte)0x03,(byte)0x01, - (byte)0x00,(byte)0x01,(byte)0x02,(byte)0x81, - (byte)0x80,(byte)0x78,(byte)0x41,(byte)0x72, - (byte)0x40,(byte)0x90,(byte)0x59,(byte)0x96, - (byte)0x5d,(byte)0xf3,(byte)0x84,(byte)0x3d, - (byte)0x99,(byte)0xd9,(byte)0x4e,(byte)0x51, - (byte)0xc2,(byte)0x52,(byte)0x62,(byte)0x8d, - (byte)0xd2,(byte)0x49,(byte)0x0b,(byte)0x73, - (byte)0x1e,(byte)0x6f,(byte)0xb2,(byte)0x31, - (byte)0x7c,(byte)0x66,(byte)0x45,(byte)0x1e, - (byte)0x7c,(byte)0xdc,(byte)0x3a,(byte)0xc2, - (byte)0x5f,(byte)0x51,(byte)0x9a,(byte)0x1e, - (byte)0xa4,(byte)0x19,(byte)0x8d,(byte)0xf4, - (byte)0xf9,(byte)0x81,(byte)0x7e,(byte)0xbe, - (byte)0x17,(byte)0xf7,(byte)0xc7,(byte)0x3c, - (byte)0x00,(byte)0xa1,(byte)0xf9,(byte)0x60, - (byte)0x82,(byte)0x34,(byte)0x8f,(byte)0x9c, - (byte)0xfd,(byte)0x0b,(byte)0x63,(byte)0x42, - (byte)0x1b,(byte)0x7f,(byte)0x45,(byte)0xf1, - (byte)0x31,(byte)0xc3,(byte)0x63,(byte)0x47, - (byte)0x5c,(byte)0xc1,(byte)0xb2,(byte)0x5f, - (byte)0x57,(byte)0xee,(byte)0x02,(byte)0x9f, - (byte)0x5e,(byte)0x08,(byte)0x48,(byte)0xba, - (byte)0x74,(byte)0xba,(byte)0x81,(byte)0xb7, - (byte)0x30,(byte)0xac,(byte)0x4c,(byte)0x01, - (byte)0x35,(byte)0xce,(byte)0x46,(byte)0x47, - (byte)0x8c,(byte)0xe4,(byte)0x62,(byte)0x36, - (byte)0x1a,(byte)0x65,(byte)0x0e,(byte)0x33, - (byte)0x56,(byte)0xf9,(byte)0xb7,(byte)0xa0, - (byte)0xc4,(byte)0xb6,(byte)0x82,(byte)0x55, - (byte)0x7d,(byte)0x36,(byte)0x55,(byte)0xc0, - (byte)0x52,(byte)0x5e,(byte)0x35,(byte)0x54, - (byte)0xbd,(byte)0x97,(byte)0x01,(byte)0x00, - (byte)0xbf,(byte)0x10,(byte)0xdc,(byte)0x1b, - (byte)0x51,(byte)0x02,(byte)0x41,(byte)0x00, - (byte)0xe7,(byte)0x68,(byte)0x03,(byte)0x3e, - (byte)0x21,(byte)0x64,(byte)0x68,(byte)0x24, - (byte)0x7b,(byte)0xd0,(byte)0x31,(byte)0xa0, - (byte)0xa2,(byte)0xd9,(byte)0x87,(byte)0x6d, - (byte)0x79,(byte)0x81,(byte)0x8f,(byte)0x8f, - (byte)0x2d,(byte)0x7a,(byte)0x95,(byte)0x2e, - (byte)0x55,(byte)0x9f,(byte)0xd7,(byte)0x86, - (byte)0x29,(byte)0x93,(byte)0xbd,(byte)0x04, - (byte)0x7e,(byte)0x4f,(byte)0xdb,(byte)0x56, - (byte)0xf1,(byte)0x75,(byte)0xd0,(byte)0x4b, - (byte)0x00,(byte)0x3a,(byte)0xe0,(byte)0x26, - (byte)0xf6,(byte)0xab,(byte)0x9e,(byte)0x0b, - (byte)0x2a,(byte)0xf4,(byte)0xa8,(byte)0xd7, - (byte)0xff,(byte)0xbe,(byte)0x01,(byte)0xeb, - (byte)0x9b,(byte)0x81,(byte)0xc7,(byte)0x5f, - (byte)0x02,(byte)0x73,(byte)0xe1,(byte)0x2b, - (byte)0x02,(byte)0x41,(byte)0x00,(byte)0xc5, - (byte)0x3d,(byte)0x78,(byte)0xab,(byte)0xe6, - (byte)0xab,(byte)0x3e,(byte)0x29,(byte)0xfd, - (byte)0x98,(byte)0xd0,(byte)0xa4,(byte)0x3e, - (byte)0x58,(byte)0xee,(byte)0x48,(byte)0x45, - (byte)0xa3,(byte)0x66,(byte)0xac,(byte)0xe9, - (byte)0x4d,(byte)0xbd,(byte)0x60,(byte)0xea, - (byte)0x24,(byte)0xff,(byte)0xed,(byte)0x0c, - (byte)0x67,(byte)0xc5,(byte)0xfd,(byte)0x36, - (byte)0x28,(byte)0xea,(byte)0x74,(byte)0x88, - (byte)0xd1,(byte)0xd1,(byte)0xad,(byte)0x58, - (byte)0xd7,(byte)0xf0,(byte)0x67,(byte)0x20, - (byte)0xc1,(byte)0xe3,(byte)0xb3,(byte)0xdb, - (byte)0x52,(byte)0xad,(byte)0xf3,(byte)0xc4, - (byte)0x21,(byte)0xd8,(byte)0x8c,(byte)0x4c, - (byte)0x41,(byte)0x27,(byte)0xdb,(byte)0xd0, - (byte)0x35,(byte)0x92,(byte)0xc7,(byte)0x02, - (byte)0x41,(byte)0x00,(byte)0xe0,(byte)0x99, - (byte)0x42,(byte)0xb4,(byte)0x76,(byte)0x02, - (byte)0x97,(byte)0x55,(byte)0xf9,(byte)0xda, - (byte)0x3b,(byte)0xa0,(byte)0xd7,(byte)0x0e, - (byte)0xdc,(byte)0xf4,(byte)0x33,(byte)0x7f, - (byte)0xbd,(byte)0xcf,(byte)0xd0,(byte)0xeb, - (byte)0x6e,(byte)0x89,(byte)0xf7,(byte)0x4f, - (byte)0x5a,(byte)0x07,(byte)0x7c,(byte)0xa9, - (byte)0x49,(byte)0x47,(byte)0x68,(byte)0x35, - (byte)0xa8,(byte)0x05,(byte)0x3d,(byte)0xfd, - (byte)0x04,(byte)0x7b,(byte)0x17,(byte)0x31, - (byte)0x0d,(byte)0xc8,(byte)0xa3,(byte)0x98, - (byte)0x34,(byte)0xa0,(byte)0x50,(byte)0x44, - (byte)0x00,(byte)0xf1,(byte)0x0c,(byte)0xe6, - (byte)0xe5,(byte)0xc4,(byte)0x41,(byte)0x3d, - (byte)0xf8,(byte)0x3d,(byte)0x4e,(byte)0x0b, - (byte)0x1c,(byte)0xdb,(byte)0x02,(byte)0x41, - (byte)0x00,(byte)0x82,(byte)0x9b,(byte)0x8a, - (byte)0xfd,(byte)0xa1,(byte)0x98,(byte)0x41, - (byte)0x68,(byte)0xc2,(byte)0xd1,(byte)0xdf, - (byte)0x4e,(byte)0xf3,(byte)0x2e,(byte)0x26, - (byte)0x53,(byte)0x5b,(byte)0x31,(byte)0xb1, - (byte)0x7a,(byte)0xcc,(byte)0x5e,(byte)0xbb, - (byte)0x09,(byte)0xa2,(byte)0xe2,(byte)0x6f, - (byte)0x4a,(byte)0x04,(byte)0x0d,(byte)0xef, - (byte)0x90,(byte)0x15,(byte)0xbe,(byte)0x10, - (byte)0x4a,(byte)0xac,(byte)0x92,(byte)0xeb, - (byte)0xda,(byte)0x72,(byte)0xdb,(byte)0x43, - (byte)0x08,(byte)0xb7,(byte)0x2b,(byte)0x4c, - (byte)0xe1,(byte)0xbb,(byte)0x58,(byte)0xcb, - (byte)0x71,(byte)0x80,(byte)0xad,(byte)0xbc, - (byte)0xdc,(byte)0x62,(byte)0x5e,(byte)0x3e, - (byte)0xcb,(byte)0x92,(byte)0xda,(byte)0xf6, - (byte)0xdf,(byte)0x02,(byte)0x40,(byte)0x4d, - (byte)0x81,(byte)0x90,(byte)0xc5,(byte)0x77, - (byte)0x30,(byte)0xb7,(byte)0x29,(byte)0x00, - (byte)0xa8,(byte)0xf1,(byte)0xb4,(byte)0xae, - (byte)0x52,(byte)0x63,(byte)0x00,(byte)0xb2, - (byte)0x2d,(byte)0x3e,(byte)0x7d,(byte)0xd6, - (byte)0x4d,(byte)0xf9,(byte)0x8a,(byte)0xc1, - (byte)0xb1,(byte)0x98,(byte)0x89,(byte)0x52, - (byte)0x40,(byte)0x14,(byte)0x1b,(byte)0x0e, - (byte)0x61,(byte)0x8f,(byte)0xf4,(byte)0xbe, - (byte)0x59,(byte)0x79,(byte)0x79,(byte)0x95, - (byte)0x19,(byte)0x5c,(byte)0x51,(byte)0x08, - (byte)0x66,(byte)0xc1,(byte)0x42,(byte)0x30, - (byte)0xb3,(byte)0x7a,(byte)0x86,(byte)0x9f, - (byte)0x3e,(byte)0xf5,(byte)0x19,(byte)0xa3, - (byte)0xae,(byte)0x64,(byte)0x69,(byte)0x14, - (byte)0x07,(byte)0x50,(byte)0x97, - }; - + private static final byte[] privateKeyInfo = { (byte) 0x30, (byte) 0x82, + (byte) 0x02, (byte) 0x77, (byte) 0x02, (byte) 0x01, (byte) 0x00, + (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a, + (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, + (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, + (byte) 0x04, (byte) 0x82, (byte) 0x02, (byte) 0x61, (byte) 0x30, + (byte) 0x82, (byte) 0x02, (byte) 0x5d, (byte) 0x02, (byte) 0x01, + (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81, (byte) 0x00, + (byte) 0xb2, (byte) 0x4a, (byte) 0x9b, (byte) 0x5b, (byte) 0xba, + (byte) 0x01, (byte) 0xc0, (byte) 0xcd, (byte) 0x65, (byte) 0x09, + (byte) 0x63, (byte) 0x70, (byte) 0x0b, (byte) 0x5a, (byte) 0x1b, + (byte) 0x92, (byte) 0x08, (byte) 0xf8, (byte) 0x55, (byte) 0x5e, + (byte) 0x7c, (byte) 0x1b, (byte) 0x50, (byte) 0x17, (byte) 0xec, + (byte) 0x44, (byte) 0x4c, (byte) 0x58, (byte) 0x42, (byte) 0x2b, + (byte) 0x41, (byte) 0x09, (byte) 0x59, (byte) 0xf2, (byte) 0xe1, + (byte) 0x5d, (byte) 0x43, (byte) 0x71, (byte) 0x4d, (byte) 0x92, + (byte) 0x03, (byte) 0x1d, (byte) 0xb6, (byte) 0x6c, (byte) 0x7f, + (byte) 0x5d, (byte) 0x48, (byte) 0xcd, (byte) 0x17, (byte) 0xec, + (byte) 0xd7, (byte) 0x4c, (byte) 0x39, (byte) 0xb1, (byte) 0x7b, + (byte) 0xe2, (byte) 0xbf, (byte) 0x96, (byte) 0x77, (byte) 0xbe, + (byte) 0xd0, (byte) 0xa0, (byte) 0xf0, (byte) 0x2d, (byte) 0x6b, + (byte) 0x24, (byte) 0xaa, (byte) 0x14, (byte) 0xba, (byte) 0x82, + (byte) 0x79, (byte) 0x10, (byte) 0x9b, (byte) 0x16, (byte) 0x68, + (byte) 0x47, (byte) 0x81, (byte) 0x54, (byte) 0xa2, (byte) 0xfa, + (byte) 0x91, (byte) 0x9e, (byte) 0x0a, (byte) 0x2a, (byte) 0x53, + (byte) 0xa6, (byte) 0xe7, (byte) 0x9e, (byte) 0x7d, (byte) 0x29, + (byte) 0x33, (byte) 0xd8, (byte) 0x05, (byte) 0xfc, (byte) 0x02, + (byte) 0x3f, (byte) 0xbd, (byte) 0xc7, (byte) 0x6e, (byte) 0xed, + (byte) 0xaa, (byte) 0x30, (byte) 0x6c, (byte) 0x5f, (byte) 0x52, + (byte) 0xed, (byte) 0x35, (byte) 0x65, (byte) 0x4b, (byte) 0x0e, + (byte) 0xc8, (byte) 0xa7, (byte) 0x12, (byte) 0x10, (byte) 0x56, + (byte) 0x37, (byte) 0xaf, (byte) 0x11, (byte) 0xfa, (byte) 0x21, + (byte) 0x0e, (byte) 0x99, (byte) 0xff, (byte) 0xfa, (byte) 0x8c, + (byte) 0x65, (byte) 0x8e, (byte) 0x6d, (byte) 0x02, (byte) 0x03, + (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x81, + (byte) 0x80, (byte) 0x78, (byte) 0x41, (byte) 0x72, (byte) 0x40, + (byte) 0x90, (byte) 0x59, (byte) 0x96, (byte) 0x5d, (byte) 0xf3, + (byte) 0x84, (byte) 0x3d, (byte) 0x99, (byte) 0xd9, (byte) 0x4e, + (byte) 0x51, (byte) 0xc2, (byte) 0x52, (byte) 0x62, (byte) 0x8d, + (byte) 0xd2, (byte) 0x49, (byte) 0x0b, (byte) 0x73, (byte) 0x1e, + (byte) 0x6f, (byte) 0xb2, (byte) 0x31, (byte) 0x7c, (byte) 0x66, + (byte) 0x45, (byte) 0x1e, (byte) 0x7c, (byte) 0xdc, (byte) 0x3a, + (byte) 0xc2, (byte) 0x5f, (byte) 0x51, (byte) 0x9a, (byte) 0x1e, + (byte) 0xa4, (byte) 0x19, (byte) 0x8d, (byte) 0xf4, (byte) 0xf9, + (byte) 0x81, (byte) 0x7e, (byte) 0xbe, (byte) 0x17, (byte) 0xf7, + (byte) 0xc7, (byte) 0x3c, (byte) 0x00, (byte) 0xa1, (byte) 0xf9, + (byte) 0x60, (byte) 0x82, (byte) 0x34, (byte) 0x8f, (byte) 0x9c, + (byte) 0xfd, (byte) 0x0b, (byte) 0x63, (byte) 0x42, (byte) 0x1b, + (byte) 0x7f, (byte) 0x45, (byte) 0xf1, (byte) 0x31, (byte) 0xc3, + (byte) 0x63, (byte) 0x47, (byte) 0x5c, (byte) 0xc1, (byte) 0xb2, + (byte) 0x5f, (byte) 0x57, (byte) 0xee, (byte) 0x02, (byte) 0x9f, + (byte) 0x5e, (byte) 0x08, (byte) 0x48, (byte) 0xba, (byte) 0x74, + (byte) 0xba, (byte) 0x81, (byte) 0xb7, (byte) 0x30, (byte) 0xac, + (byte) 0x4c, (byte) 0x01, (byte) 0x35, (byte) 0xce, (byte) 0x46, + (byte) 0x47, (byte) 0x8c, (byte) 0xe4, (byte) 0x62, (byte) 0x36, + (byte) 0x1a, (byte) 0x65, (byte) 0x0e, (byte) 0x33, (byte) 0x56, + (byte) 0xf9, (byte) 0xb7, (byte) 0xa0, (byte) 0xc4, (byte) 0xb6, + (byte) 0x82, (byte) 0x55, (byte) 0x7d, (byte) 0x36, (byte) 0x55, + (byte) 0xc0, (byte) 0x52, (byte) 0x5e, (byte) 0x35, (byte) 0x54, + (byte) 0xbd, (byte) 0x97, (byte) 0x01, (byte) 0x00, (byte) 0xbf, + (byte) 0x10, (byte) 0xdc, (byte) 0x1b, (byte) 0x51, (byte) 0x02, + (byte) 0x41, (byte) 0x00, (byte) 0xe7, (byte) 0x68, (byte) 0x03, + (byte) 0x3e, (byte) 0x21, (byte) 0x64, (byte) 0x68, (byte) 0x24, + (byte) 0x7b, (byte) 0xd0, (byte) 0x31, (byte) 0xa0, (byte) 0xa2, + (byte) 0xd9, (byte) 0x87, (byte) 0x6d, (byte) 0x79, (byte) 0x81, + (byte) 0x8f, (byte) 0x8f, (byte) 0x2d, (byte) 0x7a, (byte) 0x95, + (byte) 0x2e, (byte) 0x55, (byte) 0x9f, (byte) 0xd7, (byte) 0x86, + (byte) 0x29, (byte) 0x93, (byte) 0xbd, (byte) 0x04, (byte) 0x7e, + (byte) 0x4f, (byte) 0xdb, (byte) 0x56, (byte) 0xf1, (byte) 0x75, + (byte) 0xd0, (byte) 0x4b, (byte) 0x00, (byte) 0x3a, (byte) 0xe0, + (byte) 0x26, (byte) 0xf6, (byte) 0xab, (byte) 0x9e, (byte) 0x0b, + (byte) 0x2a, (byte) 0xf4, (byte) 0xa8, (byte) 0xd7, (byte) 0xff, + (byte) 0xbe, (byte) 0x01, (byte) 0xeb, (byte) 0x9b, (byte) 0x81, + (byte) 0xc7, (byte) 0x5f, (byte) 0x02, (byte) 0x73, (byte) 0xe1, + (byte) 0x2b, (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xc5, + (byte) 0x3d, (byte) 0x78, (byte) 0xab, (byte) 0xe6, (byte) 0xab, + (byte) 0x3e, (byte) 0x29, (byte) 0xfd, (byte) 0x98, (byte) 0xd0, + (byte) 0xa4, (byte) 0x3e, (byte) 0x58, (byte) 0xee, (byte) 0x48, + (byte) 0x45, (byte) 0xa3, (byte) 0x66, (byte) 0xac, (byte) 0xe9, + (byte) 0x4d, (byte) 0xbd, (byte) 0x60, (byte) 0xea, (byte) 0x24, + (byte) 0xff, (byte) 0xed, (byte) 0x0c, (byte) 0x67, (byte) 0xc5, + (byte) 0xfd, (byte) 0x36, (byte) 0x28, (byte) 0xea, (byte) 0x74, + (byte) 0x88, (byte) 0xd1, (byte) 0xd1, (byte) 0xad, (byte) 0x58, + (byte) 0xd7, (byte) 0xf0, (byte) 0x67, (byte) 0x20, (byte) 0xc1, + (byte) 0xe3, (byte) 0xb3, (byte) 0xdb, (byte) 0x52, (byte) 0xad, + (byte) 0xf3, (byte) 0xc4, (byte) 0x21, (byte) 0xd8, (byte) 0x8c, + (byte) 0x4c, (byte) 0x41, (byte) 0x27, (byte) 0xdb, (byte) 0xd0, + (byte) 0x35, (byte) 0x92, (byte) 0xc7, (byte) 0x02, (byte) 0x41, + (byte) 0x00, (byte) 0xe0, (byte) 0x99, (byte) 0x42, (byte) 0xb4, + (byte) 0x76, (byte) 0x02, (byte) 0x97, (byte) 0x55, (byte) 0xf9, + (byte) 0xda, (byte) 0x3b, (byte) 0xa0, (byte) 0xd7, (byte) 0x0e, + (byte) 0xdc, (byte) 0xf4, (byte) 0x33, (byte) 0x7f, (byte) 0xbd, + (byte) 0xcf, (byte) 0xd0, (byte) 0xeb, (byte) 0x6e, (byte) 0x89, + (byte) 0xf7, (byte) 0x4f, (byte) 0x5a, (byte) 0x07, (byte) 0x7c, + (byte) 0xa9, (byte) 0x49, (byte) 0x47, (byte) 0x68, (byte) 0x35, + (byte) 0xa8, (byte) 0x05, (byte) 0x3d, (byte) 0xfd, (byte) 0x04, + (byte) 0x7b, (byte) 0x17, (byte) 0x31, (byte) 0x0d, (byte) 0xc8, + (byte) 0xa3, (byte) 0x98, (byte) 0x34, (byte) 0xa0, (byte) 0x50, + (byte) 0x44, (byte) 0x00, (byte) 0xf1, (byte) 0x0c, (byte) 0xe6, + (byte) 0xe5, (byte) 0xc4, (byte) 0x41, (byte) 0x3d, (byte) 0xf8, + (byte) 0x3d, (byte) 0x4e, (byte) 0x0b, (byte) 0x1c, (byte) 0xdb, + (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0x82, (byte) 0x9b, + (byte) 0x8a, (byte) 0xfd, (byte) 0xa1, (byte) 0x98, (byte) 0x41, + (byte) 0x68, (byte) 0xc2, (byte) 0xd1, (byte) 0xdf, (byte) 0x4e, + (byte) 0xf3, (byte) 0x2e, (byte) 0x26, (byte) 0x53, (byte) 0x5b, + (byte) 0x31, (byte) 0xb1, (byte) 0x7a, (byte) 0xcc, (byte) 0x5e, + (byte) 0xbb, (byte) 0x09, (byte) 0xa2, (byte) 0xe2, (byte) 0x6f, + (byte) 0x4a, (byte) 0x04, (byte) 0x0d, (byte) 0xef, (byte) 0x90, + (byte) 0x15, (byte) 0xbe, (byte) 0x10, (byte) 0x4a, (byte) 0xac, + (byte) 0x92, (byte) 0xeb, (byte) 0xda, (byte) 0x72, (byte) 0xdb, + (byte) 0x43, (byte) 0x08, (byte) 0xb7, (byte) 0x2b, (byte) 0x4c, + (byte) 0xe1, (byte) 0xbb, (byte) 0x58, (byte) 0xcb, (byte) 0x71, + (byte) 0x80, (byte) 0xad, (byte) 0xbc, (byte) 0xdc, (byte) 0x62, + (byte) 0x5e, (byte) 0x3e, (byte) 0xcb, (byte) 0x92, (byte) 0xda, + (byte) 0xf6, (byte) 0xdf, (byte) 0x02, (byte) 0x40, (byte) 0x4d, + (byte) 0x81, (byte) 0x90, (byte) 0xc5, (byte) 0x77, (byte) 0x30, + (byte) 0xb7, (byte) 0x29, (byte) 0x00, (byte) 0xa8, (byte) 0xf1, + (byte) 0xb4, (byte) 0xae, (byte) 0x52, (byte) 0x63, (byte) 0x00, + (byte) 0xb2, (byte) 0x2d, (byte) 0x3e, (byte) 0x7d, (byte) 0xd6, + (byte) 0x4d, (byte) 0xf9, (byte) 0x8a, (byte) 0xc1, (byte) 0xb1, + (byte) 0x98, (byte) 0x89, (byte) 0x52, (byte) 0x40, (byte) 0x14, + (byte) 0x1b, (byte) 0x0e, (byte) 0x61, (byte) 0x8f, (byte) 0xf4, + (byte) 0xbe, (byte) 0x59, (byte) 0x79, (byte) 0x79, (byte) 0x95, + (byte) 0x19, (byte) 0x5c, (byte) 0x51, (byte) 0x08, (byte) 0x66, + (byte) 0xc1, (byte) 0x42, (byte) 0x30, (byte) 0xb3, (byte) 0x7a, + (byte) 0x86, (byte) 0x9f, (byte) 0x3e, (byte) 0xf5, (byte) 0x19, + (byte) 0xa3, (byte) 0xae, (byte) 0x64, (byte) 0x69, (byte) 0x14, + (byte) 0x07, (byte) 0x50, (byte) 0x97, }; + // valid PrivateKeyInfo encoding (Damaged) - private static final byte[] privateKeyInfoDamaged = { - (byte)0x30,(byte)0x82,(byte)0x02,(byte)0x77, - (byte)0x02,(byte)0x01,(byte)0x00,(byte)0x30, - (byte)0x0d,(byte)0x06,(byte)0x09,(byte)0x2a, - (byte)0x86,(byte)0x48,(byte)0x86,(byte)0xf7, - (byte)0x0d,(byte)0x01,(byte)0x01,(byte)0x01, - (byte)0x05,(byte)0x00, - (byte)0x04, // private key octet str - (byte)0x82,(byte)0x02, - (byte)0x62, // Damage: l=460->461 (0x61->0x62) - (byte)0x30,(byte)0x82, - (byte)0x02,(byte)0x5d,(byte)0x02,(byte)0x01, - (byte)0x00,(byte)0x02,(byte)0x81,(byte)0x81, - (byte)0x00,(byte)0xb2,(byte)0x4a,(byte)0x9b, - (byte)0x5b,(byte)0xba,(byte)0x01,(byte)0xc0, - (byte)0xcd,(byte)0x65,(byte)0x09,(byte)0x63, - (byte)0x70,(byte)0x0b,(byte)0x5a,(byte)0x1b, - (byte)0x92,(byte)0x08,(byte)0xf8,(byte)0x55, - (byte)0x5e,(byte)0x7c,(byte)0x1b,(byte)0x50, - (byte)0x17,(byte)0xec,(byte)0x44,(byte)0x4c, - (byte)0x58,(byte)0x42,(byte)0x2b,(byte)0x41, - (byte)0x09,(byte)0x59,(byte)0xf2,(byte)0xe1, - (byte)0x5d,(byte)0x43,(byte)0x71,(byte)0x4d, - (byte)0x92,(byte)0x03,(byte)0x1d,(byte)0xb6, - (byte)0x6c,(byte)0x7f,(byte)0x5d,(byte)0x48, - (byte)0xcd,(byte)0x17,(byte)0xec,(byte)0xd7, - (byte)0x4c,(byte)0x39,(byte)0xb1,(byte)0x7b, - (byte)0xe2,(byte)0xbf,(byte)0x96,(byte)0x77, - (byte)0xbe,(byte)0xd0,(byte)0xa0,(byte)0xf0, - (byte)0x2d,(byte)0x6b,(byte)0x24,(byte)0xaa, - (byte)0x14,(byte)0xba,(byte)0x82,(byte)0x79, - (byte)0x10,(byte)0x9b,(byte)0x16,(byte)0x68, - (byte)0x47,(byte)0x81,(byte)0x54,(byte)0xa2, - (byte)0xfa,(byte)0x91,(byte)0x9e,(byte)0x0a, - (byte)0x2a,(byte)0x53,(byte)0xa6,(byte)0xe7, - (byte)0x9e,(byte)0x7d,(byte)0x29,(byte)0x33, - (byte)0xd8,(byte)0x05,(byte)0xfc,(byte)0x02, - (byte)0x3f,(byte)0xbd,(byte)0xc7,(byte)0x6e, - (byte)0xed,(byte)0xaa,(byte)0x30,(byte)0x6c, - (byte)0x5f,(byte)0x52,(byte)0xed,(byte)0x35, - (byte)0x65,(byte)0x4b,(byte)0x0e,(byte)0xc8, - (byte)0xa7,(byte)0x12,(byte)0x10,(byte)0x56, - (byte)0x37,(byte)0xaf,(byte)0x11,(byte)0xfa, - (byte)0x21,(byte)0x0e,(byte)0x99,(byte)0xff, - (byte)0xfa,(byte)0x8c,(byte)0x65,(byte)0x8e, - (byte)0x6d,(byte)0x02,(byte)0x03,(byte)0x01, - (byte)0x00,(byte)0x01,(byte)0x02,(byte)0x81, - (byte)0x80,(byte)0x78,(byte)0x41,(byte)0x72, - (byte)0x40,(byte)0x90,(byte)0x59,(byte)0x96, - (byte)0x5d,(byte)0xf3,(byte)0x84,(byte)0x3d, - (byte)0x99,(byte)0xd9,(byte)0x4e,(byte)0x51, - (byte)0xc2,(byte)0x52,(byte)0x62,(byte)0x8d, - (byte)0xd2,(byte)0x49,(byte)0x0b,(byte)0x73, - (byte)0x1e,(byte)0x6f,(byte)0xb2,(byte)0x31, - (byte)0x7c,(byte)0x66,(byte)0x45,(byte)0x1e, - (byte)0x7c,(byte)0xdc,(byte)0x3a,(byte)0xc2, - (byte)0x5f,(byte)0x51,(byte)0x9a,(byte)0x1e, - (byte)0xa4,(byte)0x19,(byte)0x8d,(byte)0xf4, - (byte)0xf9,(byte)0x81,(byte)0x7e,(byte)0xbe, - (byte)0x17,(byte)0xf7,(byte)0xc7,(byte)0x3c, - (byte)0x00,(byte)0xa1,(byte)0xf9,(byte)0x60, - (byte)0x82,(byte)0x34,(byte)0x8f,(byte)0x9c, - (byte)0xfd,(byte)0x0b,(byte)0x63,(byte)0x42, - (byte)0x1b,(byte)0x7f,(byte)0x45,(byte)0xf1, - (byte)0x31,(byte)0xc3,(byte)0x63,(byte)0x47, - (byte)0x5c,(byte)0xc1,(byte)0xb2,(byte)0x5f, - (byte)0x57,(byte)0xee,(byte)0x02,(byte)0x9f, - (byte)0x5e,(byte)0x08,(byte)0x48,(byte)0xba, - (byte)0x74,(byte)0xba,(byte)0x81,(byte)0xb7, - (byte)0x30,(byte)0xac,(byte)0x4c,(byte)0x01, - (byte)0x35,(byte)0xce,(byte)0x46,(byte)0x47, - (byte)0x8c,(byte)0xe4,(byte)0x62,(byte)0x36, - (byte)0x1a,(byte)0x65,(byte)0x0e,(byte)0x33, - (byte)0x56,(byte)0xf9,(byte)0xb7,(byte)0xa0, - (byte)0xc4,(byte)0xb6,(byte)0x82,(byte)0x55, - (byte)0x7d,(byte)0x36,(byte)0x55,(byte)0xc0, - (byte)0x52,(byte)0x5e,(byte)0x35,(byte)0x54, - (byte)0xbd,(byte)0x97,(byte)0x01,(byte)0x00, - (byte)0xbf,(byte)0x10,(byte)0xdc,(byte)0x1b, - (byte)0x51,(byte)0x02,(byte)0x41,(byte)0x00, - (byte)0xe7,(byte)0x68,(byte)0x03,(byte)0x3e, - (byte)0x21,(byte)0x64,(byte)0x68,(byte)0x24, - (byte)0x7b,(byte)0xd0,(byte)0x31,(byte)0xa0, - (byte)0xa2,(byte)0xd9,(byte)0x87,(byte)0x6d, - (byte)0x79,(byte)0x81,(byte)0x8f,(byte)0x8f, - (byte)0x2d,(byte)0x7a,(byte)0x95,(byte)0x2e, - (byte)0x55,(byte)0x9f,(byte)0xd7,(byte)0x86, - (byte)0x29,(byte)0x93,(byte)0xbd,(byte)0x04, - (byte)0x7e,(byte)0x4f,(byte)0xdb,(byte)0x56, - (byte)0xf1,(byte)0x75,(byte)0xd0,(byte)0x4b, - (byte)0x00,(byte)0x3a,(byte)0xe0,(byte)0x26, - (byte)0xf6,(byte)0xab,(byte)0x9e,(byte)0x0b, - (byte)0x2a,(byte)0xf4,(byte)0xa8,(byte)0xd7, - (byte)0xff,(byte)0xbe,(byte)0x01,(byte)0xeb, - (byte)0x9b,(byte)0x81,(byte)0xc7,(byte)0x5f, - (byte)0x02,(byte)0x73,(byte)0xe1,(byte)0x2b, - (byte)0x02,(byte)0x41,(byte)0x00,(byte)0xc5, - (byte)0x3d,(byte)0x78,(byte)0xab,(byte)0xe6, - (byte)0xab,(byte)0x3e,(byte)0x29,(byte)0xfd, // 88 - (byte)0x98,(byte)0xd0,(byte)0xa4,(byte)0x3e, - (byte)0x58,(byte)0xee,(byte)0x48,(byte)0x45, - (byte)0xa3,(byte)0x66,(byte)0xac,(byte)0xe9, - (byte)0x4d,(byte)0xbd,(byte)0x60,(byte)0xea, - (byte)0x24,(byte)0xff,(byte)0xed,(byte)0x0c, - (byte)0x67,(byte)0xc5,(byte)0xfd,(byte)0x36, - (byte)0x28,(byte)0xea,(byte)0x74,(byte)0x88, - (byte)0xd1,(byte)0xd1,(byte)0xad,(byte)0x58, - (byte)0xd7,(byte)0xf0,(byte)0x67,(byte)0x20, - (byte)0xc1,(byte)0xe3,(byte)0xb3,(byte)0xdb, - (byte)0x52,(byte)0xad,(byte)0xf3,(byte)0xc4, - (byte)0x21,(byte)0xd8,(byte)0x8c,(byte)0x4c, - (byte)0x41,(byte)0x27,(byte)0xdb,(byte)0xd0, - (byte)0x35,(byte)0x92,(byte)0xc7,(byte)0x02, - (byte)0x41,(byte)0x00,(byte)0xe0,(byte)0x99, - (byte)0x42,(byte)0xb4,(byte)0x76,(byte)0x02, - (byte)0x97,(byte)0x55,(byte)0xf9,(byte)0xda, - (byte)0x3b,(byte)0xa0,(byte)0xd7,(byte)0x0e, - (byte)0xdc,(byte)0xf4,(byte)0x33,(byte)0x7f, - (byte)0xbd,(byte)0xcf,(byte)0xd0,(byte)0xeb, - (byte)0x6e,(byte)0x89,(byte)0xf7,(byte)0x4f, - (byte)0x5a,(byte)0x07,(byte)0x7c,(byte)0xa9, - (byte)0x49,(byte)0x47,(byte)0x68,(byte)0x35, - (byte)0xa8,(byte)0x05,(byte)0x3d,(byte)0xfd, - (byte)0x04,(byte)0x7b,(byte)0x17,(byte)0x31, - (byte)0x0d,(byte)0xc8,(byte)0xa3,(byte)0x98, - (byte)0x34,(byte)0xa0,(byte)0x50,(byte)0x44, - (byte)0x00,(byte)0xf1,(byte)0x0c,(byte)0xe6, - (byte)0xe5,(byte)0xc4,(byte)0x41,(byte)0x3d, - (byte)0xf8,(byte)0x3d,(byte)0x4e,(byte)0x0b, // 118 - (byte)0x1c,(byte)0xdb,(byte)0x02,(byte)0x41, - (byte)0x00,(byte)0x82,(byte)0x9b,(byte)0x8a, - (byte)0xfd,(byte)0xa1,(byte)0x98,(byte)0x41, - (byte)0x68,(byte)0xc2,(byte)0xd1,(byte)0xdf, - (byte)0x4e,(byte)0xf3,(byte)0x2e,(byte)0x26, - (byte)0x53,(byte)0x5b,(byte)0x31,(byte)0xb1, - (byte)0x7a,(byte)0xcc,(byte)0x5e,(byte)0xbb, - (byte)0x09,(byte)0xa2,(byte)0xe2,(byte)0x6f, - (byte)0x4a,(byte)0x04,(byte)0x0d,(byte)0xef, - (byte)0x90,(byte)0x15,(byte)0xbe,(byte)0x10, - (byte)0x4a,(byte)0xac,(byte)0x92,(byte)0xeb, - (byte)0xda,(byte)0x72,(byte)0xdb,(byte)0x43, - (byte)0x08,(byte)0xb7,(byte)0x2b,(byte)0x4c, - (byte)0xe1,(byte)0xbb,(byte)0x58,(byte)0xcb, - (byte)0x71,(byte)0x80,(byte)0xad,(byte)0xbc, - (byte)0xdc,(byte)0x62,(byte)0x5e,(byte)0x3e, - (byte)0xcb,(byte)0x92,(byte)0xda,(byte)0xf6, - (byte)0xdf,(byte)0x02,(byte)0x40,(byte)0x4d, - (byte)0x81,(byte)0x90,(byte)0xc5,(byte)0x77, - (byte)0x30,(byte)0xb7,(byte)0x29,(byte)0x00, - (byte)0xa8,(byte)0xf1,(byte)0xb4,(byte)0xae, - (byte)0x52,(byte)0x63,(byte)0x00,(byte)0xb2, // 140 - (byte)0x2d,(byte)0x3e,(byte)0x7d,(byte)0xd6, - (byte)0x4d,(byte)0xf9,(byte)0x8a,(byte)0xc1, - (byte)0xb1,(byte)0x98,(byte)0x89,(byte)0x52, - (byte)0x40,(byte)0x14,(byte)0x1b,(byte)0x0e, - (byte)0x61,(byte)0x8f,(byte)0xf4,(byte)0xbe, - (byte)0x59,(byte)0x79,(byte)0x79,(byte)0x95, - (byte)0x19,(byte)0x5c,(byte)0x51,(byte)0x08, - (byte)0x66,(byte)0xc1,(byte)0x42,(byte)0x30, - (byte)0xb3,(byte)0x7a,(byte)0x86,(byte)0x9f, - (byte)0x3e,(byte)0xf5,(byte)0x19,(byte)0xa3, // 150 - (byte)0xae,(byte)0x64,(byte)0x69,(byte)0x14, - (byte)0x07,(byte)0x50,(byte)0x97, - }; -} + private static final byte[] privateKeyInfoDamaged = { (byte) 0x30, + (byte) 0x82, (byte) 0x02, (byte) 0x77, (byte) 0x02, (byte) 0x01, + (byte) 0x00, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, + (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, + (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x05, + (byte) 0x00, (byte) 0x04, // private key octet str + (byte) 0x82, (byte) 0x02, (byte) 0x62, // Damage: l=460->461 + // (0x61->0x62) + (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x5d, (byte) 0x02, + (byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81, + (byte) 0x00, (byte) 0xb2, (byte) 0x4a, (byte) 0x9b, (byte) 0x5b, + (byte) 0xba, (byte) 0x01, (byte) 0xc0, (byte) 0xcd, (byte) 0x65, + (byte) 0x09, (byte) 0x63, (byte) 0x70, (byte) 0x0b, (byte) 0x5a, + (byte) 0x1b, (byte) 0x92, (byte) 0x08, (byte) 0xf8, (byte) 0x55, + (byte) 0x5e, (byte) 0x7c, (byte) 0x1b, (byte) 0x50, (byte) 0x17, + (byte) 0xec, (byte) 0x44, (byte) 0x4c, (byte) 0x58, (byte) 0x42, + (byte) 0x2b, (byte) 0x41, (byte) 0x09, (byte) 0x59, (byte) 0xf2, + (byte) 0xe1, (byte) 0x5d, (byte) 0x43, (byte) 0x71, (byte) 0x4d, + (byte) 0x92, (byte) 0x03, (byte) 0x1d, (byte) 0xb6, (byte) 0x6c, + (byte) 0x7f, (byte) 0x5d, (byte) 0x48, (byte) 0xcd, (byte) 0x17, + (byte) 0xec, (byte) 0xd7, (byte) 0x4c, (byte) 0x39, (byte) 0xb1, + (byte) 0x7b, (byte) 0xe2, (byte) 0xbf, (byte) 0x96, (byte) 0x77, + (byte) 0xbe, (byte) 0xd0, (byte) 0xa0, (byte) 0xf0, (byte) 0x2d, + (byte) 0x6b, (byte) 0x24, (byte) 0xaa, (byte) 0x14, (byte) 0xba, + (byte) 0x82, (byte) 0x79, (byte) 0x10, (byte) 0x9b, (byte) 0x16, + (byte) 0x68, (byte) 0x47, (byte) 0x81, (byte) 0x54, (byte) 0xa2, + (byte) 0xfa, (byte) 0x91, (byte) 0x9e, (byte) 0x0a, (byte) 0x2a, + (byte) 0x53, (byte) 0xa6, (byte) 0xe7, (byte) 0x9e, (byte) 0x7d, + (byte) 0x29, (byte) 0x33, (byte) 0xd8, (byte) 0x05, (byte) 0xfc, + (byte) 0x02, (byte) 0x3f, (byte) 0xbd, (byte) 0xc7, (byte) 0x6e, + (byte) 0xed, (byte) 0xaa, (byte) 0x30, (byte) 0x6c, (byte) 0x5f, + (byte) 0x52, (byte) 0xed, (byte) 0x35, (byte) 0x65, (byte) 0x4b, + (byte) 0x0e, (byte) 0xc8, (byte) 0xa7, (byte) 0x12, (byte) 0x10, + (byte) 0x56, (byte) 0x37, (byte) 0xaf, (byte) 0x11, (byte) 0xfa, + (byte) 0x21, (byte) 0x0e, (byte) 0x99, (byte) 0xff, (byte) 0xfa, + (byte) 0x8c, (byte) 0x65, (byte) 0x8e, (byte) 0x6d, (byte) 0x02, + (byte) 0x03, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, + (byte) 0x81, (byte) 0x80, (byte) 0x78, (byte) 0x41, (byte) 0x72, + (byte) 0x40, (byte) 0x90, (byte) 0x59, (byte) 0x96, (byte) 0x5d, + (byte) 0xf3, (byte) 0x84, (byte) 0x3d, (byte) 0x99, (byte) 0xd9, + (byte) 0x4e, (byte) 0x51, (byte) 0xc2, (byte) 0x52, (byte) 0x62, + (byte) 0x8d, (byte) 0xd2, (byte) 0x49, (byte) 0x0b, (byte) 0x73, + (byte) 0x1e, (byte) 0x6f, (byte) 0xb2, (byte) 0x31, (byte) 0x7c, + (byte) 0x66, (byte) 0x45, (byte) 0x1e, (byte) 0x7c, (byte) 0xdc, + (byte) 0x3a, (byte) 0xc2, (byte) 0x5f, (byte) 0x51, (byte) 0x9a, + (byte) 0x1e, (byte) 0xa4, (byte) 0x19, (byte) 0x8d, (byte) 0xf4, + (byte) 0xf9, (byte) 0x81, (byte) 0x7e, (byte) 0xbe, (byte) 0x17, + (byte) 0xf7, (byte) 0xc7, (byte) 0x3c, (byte) 0x00, (byte) 0xa1, + (byte) 0xf9, (byte) 0x60, (byte) 0x82, (byte) 0x34, (byte) 0x8f, + (byte) 0x9c, (byte) 0xfd, (byte) 0x0b, (byte) 0x63, (byte) 0x42, + (byte) 0x1b, (byte) 0x7f, (byte) 0x45, (byte) 0xf1, (byte) 0x31, + (byte) 0xc3, (byte) 0x63, (byte) 0x47, (byte) 0x5c, (byte) 0xc1, + (byte) 0xb2, (byte) 0x5f, (byte) 0x57, (byte) 0xee, (byte) 0x02, + (byte) 0x9f, (byte) 0x5e, (byte) 0x08, (byte) 0x48, (byte) 0xba, + (byte) 0x74, (byte) 0xba, (byte) 0x81, (byte) 0xb7, (byte) 0x30, + (byte) 0xac, (byte) 0x4c, (byte) 0x01, (byte) 0x35, (byte) 0xce, + (byte) 0x46, (byte) 0x47, (byte) 0x8c, (byte) 0xe4, (byte) 0x62, + (byte) 0x36, (byte) 0x1a, (byte) 0x65, (byte) 0x0e, (byte) 0x33, + (byte) 0x56, (byte) 0xf9, (byte) 0xb7, (byte) 0xa0, (byte) 0xc4, + (byte) 0xb6, (byte) 0x82, (byte) 0x55, (byte) 0x7d, (byte) 0x36, + (byte) 0x55, (byte) 0xc0, (byte) 0x52, (byte) 0x5e, (byte) 0x35, + (byte) 0x54, (byte) 0xbd, (byte) 0x97, (byte) 0x01, (byte) 0x00, + (byte) 0xbf, (byte) 0x10, (byte) 0xdc, (byte) 0x1b, (byte) 0x51, + (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xe7, (byte) 0x68, + (byte) 0x03, (byte) 0x3e, (byte) 0x21, (byte) 0x64, (byte) 0x68, + (byte) 0x24, (byte) 0x7b, (byte) 0xd0, (byte) 0x31, (byte) 0xa0, + (byte) 0xa2, (byte) 0xd9, (byte) 0x87, (byte) 0x6d, (byte) 0x79, + (byte) 0x81, (byte) 0x8f, (byte) 0x8f, (byte) 0x2d, (byte) 0x7a, + (byte) 0x95, (byte) 0x2e, (byte) 0x55, (byte) 0x9f, (byte) 0xd7, + (byte) 0x86, (byte) 0x29, (byte) 0x93, (byte) 0xbd, (byte) 0x04, + (byte) 0x7e, (byte) 0x4f, (byte) 0xdb, (byte) 0x56, (byte) 0xf1, + (byte) 0x75, (byte) 0xd0, (byte) 0x4b, (byte) 0x00, (byte) 0x3a, + (byte) 0xe0, (byte) 0x26, (byte) 0xf6, (byte) 0xab, (byte) 0x9e, + (byte) 0x0b, (byte) 0x2a, (byte) 0xf4, (byte) 0xa8, (byte) 0xd7, + (byte) 0xff, (byte) 0xbe, (byte) 0x01, (byte) 0xeb, (byte) 0x9b, + (byte) 0x81, (byte) 0xc7, (byte) 0x5f, (byte) 0x02, (byte) 0x73, + (byte) 0xe1, (byte) 0x2b, (byte) 0x02, (byte) 0x41, (byte) 0x00, + (byte) 0xc5, (byte) 0x3d, (byte) 0x78, (byte) 0xab, (byte) 0xe6, + (byte) 0xab, (byte) 0x3e, (byte) 0x29, (byte) 0xfd, // 88 + (byte) 0x98, (byte) 0xd0, (byte) 0xa4, (byte) 0x3e, (byte) 0x58, + (byte) 0xee, (byte) 0x48, (byte) 0x45, (byte) 0xa3, (byte) 0x66, + (byte) 0xac, (byte) 0xe9, (byte) 0x4d, (byte) 0xbd, (byte) 0x60, + (byte) 0xea, (byte) 0x24, (byte) 0xff, (byte) 0xed, (byte) 0x0c, + (byte) 0x67, (byte) 0xc5, (byte) 0xfd, (byte) 0x36, (byte) 0x28, + (byte) 0xea, (byte) 0x74, (byte) 0x88, (byte) 0xd1, (byte) 0xd1, + (byte) 0xad, (byte) 0x58, (byte) 0xd7, (byte) 0xf0, (byte) 0x67, + (byte) 0x20, (byte) 0xc1, (byte) 0xe3, (byte) 0xb3, (byte) 0xdb, + (byte) 0x52, (byte) 0xad, (byte) 0xf3, (byte) 0xc4, (byte) 0x21, + (byte) 0xd8, (byte) 0x8c, (byte) 0x4c, (byte) 0x41, (byte) 0x27, + (byte) 0xdb, (byte) 0xd0, (byte) 0x35, (byte) 0x92, (byte) 0xc7, + (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xe0, (byte) 0x99, + (byte) 0x42, (byte) 0xb4, (byte) 0x76, (byte) 0x02, (byte) 0x97, + (byte) 0x55, (byte) 0xf9, (byte) 0xda, (byte) 0x3b, (byte) 0xa0, + (byte) 0xd7, (byte) 0x0e, (byte) 0xdc, (byte) 0xf4, (byte) 0x33, + (byte) 0x7f, (byte) 0xbd, (byte) 0xcf, (byte) 0xd0, (byte) 0xeb, + (byte) 0x6e, (byte) 0x89, (byte) 0xf7, (byte) 0x4f, (byte) 0x5a, + (byte) 0x07, (byte) 0x7c, (byte) 0xa9, (byte) 0x49, (byte) 0x47, + (byte) 0x68, (byte) 0x35, (byte) 0xa8, (byte) 0x05, (byte) 0x3d, + (byte) 0xfd, (byte) 0x04, (byte) 0x7b, (byte) 0x17, (byte) 0x31, + (byte) 0x0d, (byte) 0xc8, (byte) 0xa3, (byte) 0x98, (byte) 0x34, + (byte) 0xa0, (byte) 0x50, (byte) 0x44, (byte) 0x00, (byte) 0xf1, + (byte) 0x0c, (byte) 0xe6, (byte) 0xe5, (byte) 0xc4, (byte) 0x41, + (byte) 0x3d, (byte) 0xf8, (byte) 0x3d, (byte) 0x4e, (byte) 0x0b, // 118 + (byte) 0x1c, (byte) 0xdb, (byte) 0x02, (byte) 0x41, (byte) 0x00, + (byte) 0x82, (byte) 0x9b, (byte) 0x8a, (byte) 0xfd, (byte) 0xa1, + (byte) 0x98, (byte) 0x41, (byte) 0x68, (byte) 0xc2, (byte) 0xd1, + (byte) 0xdf, (byte) 0x4e, (byte) 0xf3, (byte) 0x2e, (byte) 0x26, + (byte) 0x53, (byte) 0x5b, (byte) 0x31, (byte) 0xb1, (byte) 0x7a, + (byte) 0xcc, (byte) 0x5e, (byte) 0xbb, (byte) 0x09, (byte) 0xa2, + (byte) 0xe2, (byte) 0x6f, (byte) 0x4a, (byte) 0x04, (byte) 0x0d, + (byte) 0xef, (byte) 0x90, (byte) 0x15, (byte) 0xbe, (byte) 0x10, + (byte) 0x4a, (byte) 0xac, (byte) 0x92, (byte) 0xeb, (byte) 0xda, + (byte) 0x72, (byte) 0xdb, (byte) 0x43, (byte) 0x08, (byte) 0xb7, + (byte) 0x2b, (byte) 0x4c, (byte) 0xe1, (byte) 0xbb, (byte) 0x58, + (byte) 0xcb, (byte) 0x71, (byte) 0x80, (byte) 0xad, (byte) 0xbc, + (byte) 0xdc, (byte) 0x62, (byte) 0x5e, (byte) 0x3e, (byte) 0xcb, + (byte) 0x92, (byte) 0xda, (byte) 0xf6, (byte) 0xdf, (byte) 0x02, + (byte) 0x40, (byte) 0x4d, (byte) 0x81, (byte) 0x90, (byte) 0xc5, + (byte) 0x77, (byte) 0x30, (byte) 0xb7, (byte) 0x29, (byte) 0x00, + (byte) 0xa8, (byte) 0xf1, (byte) 0xb4, (byte) 0xae, (byte) 0x52, + (byte) 0x63, (byte) 0x00, (byte) 0xb2, // 140 + (byte) 0x2d, (byte) 0x3e, (byte) 0x7d, (byte) 0xd6, (byte) 0x4d, + (byte) 0xf9, (byte) 0x8a, (byte) 0xc1, (byte) 0xb1, (byte) 0x98, + (byte) 0x89, (byte) 0x52, (byte) 0x40, (byte) 0x14, (byte) 0x1b, + (byte) 0x0e, (byte) 0x61, (byte) 0x8f, (byte) 0xf4, (byte) 0xbe, + (byte) 0x59, (byte) 0x79, (byte) 0x79, (byte) 0x95, (byte) 0x19, + (byte) 0x5c, (byte) 0x51, (byte) 0x08, (byte) 0x66, (byte) 0xc1, + (byte) 0x42, (byte) 0x30, (byte) 0xb3, (byte) 0x7a, (byte) 0x86, + (byte) 0x9f, (byte) 0x3e, (byte) 0xf5, (byte) 0x19, (byte) 0xa3, // 150 + (byte) 0xae, (byte) 0x64, (byte) 0x69, (byte) 0x14, (byte) 0x07, + (byte) 0x50, (byte) 0x97, }; +} \ No newline at end of file Index: modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java =================================================================== --- modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java (revision 410067) +++ modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/KeyAgreementTest.java (working copy) @@ -50,17 +50,8 @@ * */ -public class KeyAgreement1Test extends TestCase { +public class KeyAgreementTest extends TestCase { - /** - * Constructor for KeyAgreement1Test. - * - * @param arg0 - */ - public KeyAgreement1Test(String arg0) { - super(arg0); - } - public static final String srvKeyAgreement = "KeyAgreement"; private static String defaultAlgorithm = "DH"; @@ -119,35 +110,6 @@ } /** - * Test for KeyAgreement constructor Assertion: returns - * KeyAgreement object - */ - public void testKeyAgreement() throws NoSuchAlgorithmException, - InvalidKeyException, IllegalStateException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - KeyAgreementSpi spi = new MyKeyAgreementSpi(); - KeyAgreement keyA = new myKeyAgreement(spi, defaultProvider, - defaultAlgorithm); - assertEquals("Incorrect algorithm", keyA.getAlgorithm(), - defaultAlgorithm); - assertEquals("Incorrect provider", keyA.getProvider(), defaultProvider); - assertNull("Incorrect result", keyA.doPhase(null, true)); - assertEquals("Incorrect result", keyA.generateSecret().length, 0); - - keyA = new myKeyAgreement(null, null, null); - assertNull("Algorithm must be null", keyA.getAlgorithm()); - assertNull("Provider must be null", keyA.getProvider()); - try { - keyA.doPhase(null, true); - fail("NullPointerEXception must be thrown"); - } catch (NullPointerException e) { - } - } - - /** * Test for getInstance(String algorithm) method Assertions: * throws NullPointerException when algorithm is null throws * NoSuchAlgorithmException when algorithm isnot available @@ -484,7 +446,6 @@ } try { kAgs[i].init(privKey, dsa, random); - fail("InvalidAlgorithmParameterException must be throw"); fail("InvalidAlgorithmParameterException or InvalidKeyException must be throw"); } catch (InvalidAlgorithmParameterException e) { } catch (InvalidKeyException e) { @@ -584,19 +545,4 @@ } } - public static void main(String args[]) { - junit.textui.TestRunner.run(KeyAgreement1Test.class); - } } - -/** - * Additional class for KeyAgreement constructor verification - */ - -class myKeyAgreement extends KeyAgreement { - - public myKeyAgreement(KeyAgreementSpi keyAgreeSpi, Provider provider, - String algorithm) { - super(keyAgreeSpi, provider, algorithm); - } -} Index: modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java =================================================================== --- modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java (revision 410067) +++ modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/SecretKeyFactoryTest.java (working copy) @@ -45,7 +45,7 @@ * */ -public class SecretKeyFactory1Test extends TestCase { +public class SecretKeyFactoryTest extends TestCase { public static final String srvSecretKeyFactory = "SecretKeyFactory"; @@ -111,15 +111,6 @@ } /** - * Constructor for SecretKeyFactoryTests. - * - * @param arg0 - */ - public SecretKeyFactory1Test(String arg0) { - super(arg0); - } - - /** * Test for SecretKeyFactory constructor * Assertion: returns SecretKeyFactory object */ @@ -424,30 +415,6 @@ } } } - /** - * Test for translateKey(SecretKey key) method - * Assertion: - * throw InvalidKeyException if parameter is inappropriate - */ - public void testSecretKeyFactory11() throws InvalidKeyException { - if (!DEFSupported) { - fail(NotSupportMsg); - return; - } - byte[] bb = new byte[10]; - SecretKeySpec secKeySpec = new SecretKeySpec(bb,defaultAlgorithm); - SecretKeyFactory[] skF = createSKFac(); - assertNotNull("SecretKeyFactory object were not created", skF); - for (int i = 0; i < skF.length; i++) { - try { - skF[i].translateKey(null); - fail("InvalidKeyException must be thrown: " + i); - } catch (InvalidKeyException e) { - } - - skF[i].translateKey(secKeySpec); - } - } } class mySecretKeyFactory extends SecretKeyFactory { Index: modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java =================================================================== --- modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java (revision 410067) +++ modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/ExemptionMechanismTest.java (working copy) @@ -21,27 +21,16 @@ package org.apache.harmony.crypto.tests.javax.crypto; -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.security.Provider; -import java.security.Security; -import java.security.spec.AlgorithmParameterSpec; import javax.crypto.ExemptionMechanism; -import javax.crypto.ExemptionMechanismException; import javax.crypto.ExemptionMechanismSpi; -import javax.crypto.ShortBufferException; -import javax.crypto.spec.SecretKeySpec; import org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi; import org.apache.harmony.security.SpiEngUtils; +import org.apache.harmony.security.SpiEngUtils.MyProvider; import junit.framework.TestCase; - - /** * Tests for ExemptionMechanism class constructors and methods * @@ -55,36 +44,6 @@ private static final String ExemptionMechanismProviderClass = "org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi"; - private static final String[] invalidValues = SpiEngUtils.invalidValues; - - private static final String[] validValues; - - static { - validValues = new String[4]; - validValues[0] = defaultAlg; - validValues[1] = defaultAlg.toLowerCase(); - validValues[2] = "eMEch"; - validValues[3] = "emecH"; - } - - Provider mProv; - - protected void setUp() throws Exception { - super.setUp(); - mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", "Provider for ExemptionMechanism testing", - srvExemptionMechanism.concat(".").concat(defaultAlg), - ExemptionMechanismProviderClass); - Security.insertProviderAt(mProv, 1); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - Security.removeProvider(mProv.getName()); - } - /** * Constructor for SecurityManagerFactoryTest2. * @@ -93,229 +52,16 @@ public ExemptionMechanismTest(String arg0) { super(arg0); } - - private void checkResult(ExemptionMechanism exMech) - throws ExemptionMechanismException, ShortBufferException, - InvalidKeyException, InvalidAlgorithmParameterException { - Key key = new MyExemptionMechanismSpi().new tmpKey("Proba", new byte[0]); - byte [] emptyA = new byte[0]; - int len = MyExemptionMechanismSpi.getLength(); - byte [] byteA = new byte[len]; - try { - exMech.genExemptionBlob(); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - try { - exMech.genExemptionBlob(byteA); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - try { - exMech.genExemptionBlob(byteA, 1); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - try { - exMech.getOutputSize(0); - fail("IllegalStateException must be thrown"); - } catch (IllegalStateException e) { - } - - exMech.init(key); - byte [] bbRes = exMech.genExemptionBlob(); - assertEquals("Incorrect length", bbRes.length, len); - assertEquals("Incorrect result", exMech.genExemptionBlob(new byte[5]), 5); - assertEquals("Incorrect result", exMech.genExemptionBlob(bbRes), len); - try { - exMech.genExemptionBlob(new byte[1], len); - fail("ShortBufferException must be thrown"); - } catch (ShortBufferException e) { - } - try { - exMech.genExemptionBlob(emptyA); - fail("ShortBufferException must be thrown"); - } catch (ShortBufferException e) { - } - - assertEquals("Incorrect result", exMech.genExemptionBlob(byteA, 1), 9); - assertEquals("Incorrect result", exMech.genExemptionBlob(new byte[20], (len - 2)), len); - - assertEquals("Incorrect output size", exMech.getOutputSize(100), 5); - - AlgorithmParameters params = null; - exMech.init(key, params); - AlgorithmParameterSpec parSpec = null; - exMech.init(key, parSpec); - key = new SecretKeySpec(new byte[10], "DSA"); - try { - exMech.init(key); - fail("ExemptionMechanismException must be throwm"); - } catch (ExemptionMechanismException e) { - assertTrue("Empty message", (e.getMessage().length() > 0)); - } - try { - exMech.init(key, params); - fail("ExemptionMechanismException must be throwm"); - } catch (ExemptionMechanismException e) { - assertTrue("Empty message", (e.getMessage().length() > 0)); - } - try { - exMech.init(key, parSpec); - fail("ExemptionMechanismException must be throwm"); - } catch (ExemptionMechanismException e) { - assertTrue("Empty message", (e.getMessage().length() > 0)); - } - } - + /** - * Test for getInstance(String algorithm) method - * Assertions: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is incorrect; - * returns ExemptionMechanism object - */ - public void testGetInstance01() throws NoSuchAlgorithmException, - ExemptionMechanismException, InvalidAlgorithmParameterException, - ShortBufferException, InvalidKeyException { - try { - ExemptionMechanism.getInstance(null); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - ExemptionMechanism.getInstance(invalidValues[i]); - fail("NoSuchAlgorithmException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - ExemptionMechanism exMech; - for (int i = 0; i < validValues.length; i++) { - exMech = ExemptionMechanism.getInstance(validValues[i]); - assertEquals("Incorrect algorithm", exMech.getName(), - validValues[i]); - assertEquals("Incorrect provider", exMech.getProvider(), mProv); - checkResult(exMech); - } - } - - /** - * Test for getInstance(String algorithm, String provider) - * method - * Assertions: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is null or incorrect; - * throws IllegalArgumentException when provider is null; - * throws NoSuchProviderException when provider is available; - * returns ExemptionMechanism object - */ - public void testGetInstance02() throws NoSuchAlgorithmException, - NoSuchProviderException, IllegalArgumentException, - ExemptionMechanismException, InvalidAlgorithmParameterException, - ShortBufferException, InvalidKeyException { - try { - ExemptionMechanism.getInstance(null, mProv.getName()); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - ExemptionMechanism.getInstance(invalidValues[i], mProv - .getName()); - fail("NoSuchAlgorithmException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - String prov = null; - for (int i = 0; i < validValues.length; i++) { - try { - ExemptionMechanism.getInstance(validValues[i], prov); - fail("IllegalArgumentException must be thrown when provider is null (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (IllegalArgumentException e) { - } - } - for (int i = 0; i < validValues.length; i++) { - for (int j = 1; j < invalidValues.length; j++) { - try { - ExemptionMechanism.getInstance(validValues[i], - invalidValues[j]); - fail("NoSuchProviderException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(" provider: ") - .concat(invalidValues[j]).concat(")")); - } catch (NoSuchProviderException e) { - } - } - } - ExemptionMechanism exMech; - for (int i = 0; i < validValues.length; i++) { - exMech = ExemptionMechanism.getInstance(validValues[i], mProv - .getName()); - assertEquals("Incorrect algorithm", exMech.getName(), - validValues[i]); - assertEquals("Incorrect provider", exMech.getProvider().getName(), - mProv.getName()); - checkResult(exMech); - } - } - - /** - * Test for getInstance(String algorithm, Provider provider) - * method - * Assertions: - * throws NullPointerException when algorithm is null; - * throws NoSuchAlgorithmException when algorithm is null or incorrect; - * throws IllegalArgumentException when provider is null; - * returns ExemptionMechanism object - */ - public void testGetInstance03() throws NoSuchAlgorithmException, - IllegalArgumentException, - ExemptionMechanismException, InvalidAlgorithmParameterException, - ShortBufferException, InvalidKeyException { - try { - ExemptionMechanism.getInstance(null, mProv); - fail("NullPointerException or NoSuchAlgorithmException should be thrown if algorithm is null"); - } catch (NullPointerException e) { - } catch (NoSuchAlgorithmException e) { - } - for (int i = 0; i < invalidValues.length; i++) { - try { - ExemptionMechanism.getInstance(invalidValues[i], mProv); - fail("NoSuchAlgorithmException must be thrown (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (NoSuchAlgorithmException e) { - } - } - Provider prov = null; - for (int i = 0; i < validValues.length; i++) { - try { - ExemptionMechanism.getInstance(validValues[i], prov); - fail("IllegalArgumentException must be thrown when provider is null (algorithm: " - .concat(invalidValues[i]).concat(")")); - } catch (IllegalArgumentException e) { - } - } - ExemptionMechanism exMech; - for (int i = 0; i < validValues.length; i++) { - exMech = ExemptionMechanism.getInstance(validValues[i], mProv); - assertEquals("Incorrect algorithm", exMech.getName(), - validValues[i]); - assertEquals("Incorrect provider", exMech.getProvider(), mProv); - checkResult(exMech); - } - } - - /** * Test for ExemptionMechanism constructor * Assertion: cretes new object using provider and mechanism name */ - public void testExemptionMechanism() throws NoSuchAlgorithmException, - ExemptionMechanismException, ShortBufferException, InvalidKeyException { + public void testExemptionMechanism() throws Exception { + Provider mProv = (new SpiEngUtils()).new MyProvider("MyExMechProvider", "Provider for ExemptionMechanism testing", + srvExemptionMechanism.concat(".").concat(defaultAlg), + ExemptionMechanismProviderClass); + ExemptionMechanismSpi spi = new MyExemptionMechanismSpi(); ExemptionMechanism em = new myEM(spi, mProv, defaultAlg); Index: modules/crypto/src/test/api/java.injected/javax/crypto/SealedObjectTest.java =================================================================== --- modules/crypto/src/test/api/java.injected/javax/crypto/SealedObjectTest.java (revision 410067) +++ modules/crypto/src/test/api/java.injected/javax/crypto/SealedObjectTest.java (working copy) @@ -55,57 +55,36 @@ * deserialized, the content od deserialized object equals to the * content of initial object. */ - public void testReadObject() { - try { - String secret = "secret string"; - SealedObject so = new SealedObject(secret, new NullCipher()); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(so); + public void testReadObject() throws Exception { + String secret = "secret string"; + SealedObject so = new SealedObject(secret, new NullCipher()); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(so); - ObjectInputStream ois = - new ObjectInputStream( - new ByteArrayInputStream(bos.toByteArray())); + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream( + bos.toByteArray())); - SealedObject so_des = (SealedObject) ois.readObject(); - assertEquals("The secret content of deserialized object " + SealedObject so_des = (SealedObject) ois.readObject(); + assertEquals("The secret content of deserialized object " + "should be equal to the secret content of initial object", secret, so_des.getObject(new NullCipher())); - assertEquals("The value returned by getAlgorithm() method of " + assertEquals("The value returned by getAlgorithm() method of " + "deserialized object should be equal to the value returned " - + "by getAlgorithm() method of initial object", - so.getAlgorithm(), so_des.getAlgorithm()); - } catch (BadPaddingException e) { - e.printStackTrace(); - fail("Unexpected BadPaddingException was thrown."); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - fail("Unexpected ClassNotFoundException was thrown."); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - fail("Unexpected IllegalBlockSizeException was thrown."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } + + "by getAlgorithm() method of initial object", so + .getAlgorithm(), so_des.getAlgorithm()); } /** - * SealedObject(Serializable object, Cipher c) method testing. - * Tests if the NullPointerException is thrown in the case of null cipher. + * SealedObject(Serializable object, Cipher c) method testing. Tests if the + * NullPointerException is thrown in the case of null cipher. */ - public void testSealedObject1() { + public void testSealedObject1() throws Exception { String secret = "secret string"; try { new SealedObject(secret, null); fail("NullPointerException should be thrown in the case " + "of null cipher."); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - fail("Unexpected IllegalBlockSizeException was thrown."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); } catch (NullPointerException e) { } } @@ -114,7 +93,7 @@ * SealedObject(SealedObject so) method testing. Tests if the * NullPointerException is thrown in the case of null SealedObject. */ - public void testSealedObject2() { + public void testSealedObject2() throws Exception { try { new SealedObject(null); fail("NullPointerException should be thrown in the case " @@ -122,306 +101,133 @@ } catch (NullPointerException e) { } - try { - String secret = "secret string"; - Cipher cipher = new NullCipher(); - SealedObject so1 = new SealedObject(secret, cipher); - SealedObject so2 = new SealedObject(so1); + String secret = "secret string"; + Cipher cipher = new NullCipher(); + SealedObject so1 = new SealedObject(secret, cipher); + SealedObject so2 = new SealedObject(so1); - assertEquals("The secret content of the object should equals " - + "to the secret content of initial object.", - secret, so2.getObject(cipher)); - assertEquals("The algorithm which was used to seal the object " - + "should be the same as the algorithm used to seal the " - + "initial object", so1.getAlgorithm(), so2.getAlgorithm()); - } catch (BadPaddingException e) { - e.printStackTrace(); - fail("Unexpected BadPaddingException was thrown."); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - fail("Unexpected ClassNotFoundException was thrown."); - } catch (NullPointerException e) { - e.printStackTrace(); - fail("Unexpected NullPointerException was thrown."); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - fail("Unexpected IllegalBlockSizeException was thrown."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } + assertEquals("The secret content of the object should equals " + + "to the secret content of initial object.", secret, so2 + .getObject(cipher)); + assertEquals("The algorithm which was used to seal the object " + + "should be the same as the algorithm used to seal the " + + "initial object", so1.getAlgorithm(), so2.getAlgorithm()); } /** - * getAlgorithm() method testing. Tests if the returned value equals - * to the corresponding value of Cipher object. + * getAlgorithm() method testing. Tests if the returned value equals to the + * corresponding value of Cipher object. */ - public void testGetAlgorithm() { - try { - String secret = "secret string"; - String algorithm = "DES"; - KeyGenerator kg = KeyGenerator.getInstance(algorithm); - Key key = kg.generateKey(); + public void testGetAlgorithm() throws Exception { + String secret = "secret string"; + String algorithm = "DES"; + KeyGenerator kg = KeyGenerator.getInstance(algorithm); + Key key = kg.generateKey(); - Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.ENCRYPT_MODE, key); - SealedObject so = new SealedObject(secret, cipher); + Cipher cipher = Cipher.getInstance(algorithm); + cipher.init(Cipher.ENCRYPT_MODE, key); + SealedObject so = new SealedObject(secret, cipher); - assertEquals("The algorithm name should be the same as used " - + "in cipher.", algorithm, so.getAlgorithm()); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - fail("Unexpected NoSuchAlgorithmException was thrown."); - } catch (NoSuchPaddingException e) { - e.printStackTrace(); - fail("Unexpected NoSuchPaddingException was thrown."); - } catch (InvalidKeyException e) { - e.printStackTrace(); - fail("Unexpected InvalidKeyException was thrown."); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - fail("Unexpected IllegalBlockSizeException was thrown."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } catch (NullPointerException e) { - e.printStackTrace(); - fail("Unexpected NullPointerException was thrown."); - } + assertEquals("The algorithm name should be the same as used " + + "in cipher.", algorithm, so.getAlgorithm()); } /** - * getObject(Key key) method testing. Tests if the object sealed - * with encryption algorithm and specified parameters can be - * retrieved by specifying the cryptographic key. + * getObject(Key key) method testing. Tests if the object sealed with + * encryption algorithm and specified parameters can be retrieved by + * specifying the cryptographic key. */ - public void testGetObject1() { - try { - KeyGenerator kg = KeyGenerator.getInstance("DES"); - Key key = kg.generateKey(); + public void testGetObject1() throws Exception { + KeyGenerator kg = KeyGenerator.getInstance("DES"); + Key key = kg.generateKey(); - IvParameterSpec ips = - new IvParameterSpec(new byte[] {1, 2, 3, 4, 5, 6, 7, 8}); + IvParameterSpec ips = new IvParameterSpec(new byte[] { 1, 2, 3, 4, 5, + 6, 7, 8 }); - Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, key, ips); + Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, key, ips); - String secret = "secret string"; - SealedObject so = new SealedObject(secret, cipher); + String secret = "secret string"; + SealedObject so = new SealedObject(secret, cipher); - assertEquals("The returned object does not equals to the " - + "original object.", - secret, so.getObject(key)); + assertEquals("The returned object does not equals to the " + + "original object.", secret, so.getObject(key)); - assertTrue("The encodedParams field of SealedObject object " - + "should contain the encoded algorithm parameters.", - Arrays.equals(so.encodedParams, - cipher.getParameters().getEncoded())); - - } catch (InvalidAlgorithmParameterException e) { - e.printStackTrace(); - fail("Unexpected InvalidAlgorithmParameterException was thrown."); - } catch (InvalidKeyException e) { - e.printStackTrace(); - fail("Unexpected InvalidKeyException was thrown."); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - fail("Unexpected ClassNotFoundException was thrown."); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - fail("Unexpected IllegalBlockSizeException was thrown."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } catch (NoSuchPaddingException e) { - e.printStackTrace(); - fail("Unexpected NoSuchPaddingException was thrown."); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - fail("Unexpected NoSuchAlgorithmException was thrown."); - } + assertTrue("The encodedParams field of SealedObject object " + + "should contain the encoded algorithm parameters.", Arrays + .equals(so.encodedParams, cipher.getParameters().getEncoded())); } /** - * getObject(Cipher c) method testing. Tests if the proper exception - * is thrown in the case of incorrect input parameters and if the - * object sealed with encryption algorithm and specified parameters - * can be retrieved by specifying the initialized Cipher object. + * getObject(Cipher c) method testing. Tests if the proper exception is + * thrown in the case of incorrect input parameters and if the object sealed + * with encryption algorithm and specified parameters can be retrieved by + * specifying the initialized Cipher object. */ - public void testGetObject2() { + public void testGetObject2() throws Exception { try { - new SealedObject("secret string", - new NullCipher()).getObject((Cipher) null); + new SealedObject("secret string", new NullCipher()) + .getObject((Cipher) null); fail("NullPointerException should be thrown in the case of " + "null cipher."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - fail("Unexpected IllegalBlockSizeException was thrown."); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - fail("Unexpected ClassNotFoundException was thrown."); - } catch (BadPaddingException e) { - e.printStackTrace(); - fail("Unexpected BadPaddingException was thrown."); } catch (NullPointerException e) { } - try { - KeyGenerator kg = KeyGenerator.getInstance("DES"); - Key key = kg.generateKey(); + KeyGenerator kg = KeyGenerator.getInstance("DES"); + Key key = kg.generateKey(); - IvParameterSpec ips = - new IvParameterSpec(new byte[] {1, 2, 3, 4, 5, 6, 7, 8}); + IvParameterSpec ips = new IvParameterSpec(new byte[] { 1, 2, 3, 4, 5, + 6, 7, 8 }); - Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, key, ips); + Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, key, ips); - String secret = "secret string"; - SealedObject so = new SealedObject(secret, cipher); + String secret = "secret string"; + SealedObject so = new SealedObject(secret, cipher); - cipher.init(Cipher.DECRYPT_MODE, key, ips); - assertEquals("The returned object does not equals to the " - + "original object.", - secret, so.getObject(cipher)); - - } catch (InvalidAlgorithmParameterException e) { - e.printStackTrace(); - fail("Unexpected InvalidAlgorithmParameterException was thrown."); - } catch (BadPaddingException e) { - e.printStackTrace(); - fail("Unexpected BadPaddingException was thrown."); - } catch (InvalidKeyException e) { - e.printStackTrace(); - fail("Unexpected InvalidKeyException was thrown."); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - fail("Unexpected ClassNotFoundException was thrown."); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - fail("Unexpected IllegalBlockSizeException was thrown."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } catch (NoSuchPaddingException e) { - e.printStackTrace(); - fail("Unexpected NoSuchPaddingException was thrown."); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - fail("Unexpected NoSuchAlgorithmException was thrown."); - } + cipher.init(Cipher.DECRYPT_MODE, key, ips); + assertEquals("The returned object does not equals to the " + + "original object.", secret, so.getObject(cipher)); } /** - * getObject(Key key, String provider) method testing. Tests if the - * proper exception is thrown in the case of incorrect input parameters - * and if the object sealed with encryption algorithm can be - * retrieved by specifying the cryptographic key and provider name. + * getObject(Key key, String provider) method testing. Tests if the proper + * exception is thrown in the case of incorrect input parameters and if the + * object sealed with encryption algorithm can be retrieved by specifying + * the cryptographic key and provider name. */ - public void testGetObject3() { + public void testGetObject3() throws Exception { try { - new SealedObject("secret string", - new NullCipher()).getObject( - new SecretKeySpec(new byte[] {0, 0, 0}, "algorithm"), - null); + new SealedObject("secret string", new NullCipher()).getObject( + new SecretKeySpec(new byte[] { 0, 0, 0 }, "algorithm"), + null); fail("IllegalArgumentException should be thrown in the case of " + "null provider."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - fail("Unexpected IllegalBlockSizeException was thrown."); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - fail("Unexpected ClassNotFoundException was thrown."); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - fail("Unexpected NoSuchAlgorithmException was thrown."); - } catch (NoSuchProviderException e) { - e.printStackTrace(); - fail("Unexpected NoSuchProviderException was thrown."); - } catch (InvalidKeyException e) { - e.printStackTrace(); - fail("Unexpected InvalidKeyException was thrown."); } catch (IllegalArgumentException e) { } try { - new SealedObject("secret string", - new NullCipher()).getObject( - new SecretKeySpec(new byte[] {0, 0, 0}, "algorithm"), - ""); + new SealedObject("secret string", new NullCipher()).getObject( + new SecretKeySpec(new byte[] { 0, 0, 0 }, "algorithm"), ""); fail("IllegalArgumentException should be thrown in the case of " + "empty provider."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - fail("Unexpected IllegalBlockSizeException was thrown."); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - fail("Unexpected ClassNotFoundException was thrown."); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - fail("Unexpected NoSuchAlgorithmException was thrown."); - } catch (NoSuchProviderException e) { - e.printStackTrace(); - fail("Unexpected NoSuchProviderException was thrown."); - } catch (InvalidKeyException e) { - e.printStackTrace(); - fail("Unexpected InvalidKeyException was thrown."); } catch (IllegalArgumentException e) { } - try { - KeyGenerator kg = KeyGenerator.getInstance("DES"); - Key key = kg.generateKey(); + KeyGenerator kg = KeyGenerator.getInstance("DES"); + Key key = kg.generateKey(); - Cipher cipher = Cipher.getInstance("DES"); - String provider = cipher.getProvider().getName(); - cipher.init(Cipher.ENCRYPT_MODE, key); + Cipher cipher = Cipher.getInstance("DES"); + String provider = cipher.getProvider().getName(); + cipher.init(Cipher.ENCRYPT_MODE, key); - String secret = "secret string"; - SealedObject so = new SealedObject(secret, cipher); + String secret = "secret string"; + SealedObject so = new SealedObject(secret, cipher); - cipher.init(Cipher.DECRYPT_MODE, key); - assertEquals("The returned object does not equals to the " - + "original object.", - secret, so.getObject(key, provider)); - } catch (NoSuchProviderException e) { - e.printStackTrace(); - fail("Unexpected NoSuchProviderException was thrown."); - } catch (InvalidKeyException e) { - e.printStackTrace(); - fail("Unexpected InvalidKeyException was thrown."); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - fail("Unexpected ClassNotFoundException was thrown."); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - fail("Unexpected IllegalBlockSizeException was thrown."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } catch (NoSuchPaddingException e) { - e.printStackTrace(); - fail("Unexpected NoSuchPaddingException was thrown."); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - fail("Unexpected NoSuchAlgorithmException was thrown."); - } + cipher.init(Cipher.DECRYPT_MODE, key); + assertEquals("The returned object does not equals to the " + + "original object.", secret, so.getObject(key, provider)); } - public static Test suite() { - return new TestSuite(SealedObjectTest.class); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } } Index: modules/crypto/src/test/api/java.injected/javax/crypto/CipherInputStreamTest.java =================================================================== --- modules/crypto/src/test/api/java.injected/javax/crypto/CipherInputStreamTest.java (revision 410067) +++ modules/crypto/src/test/api/java.injected/javax/crypto/CipherInputStreamTest.java (working copy) @@ -55,51 +55,40 @@ * CipherInputStream uses NullCipher if Cipher is not specified * in the constructor. */ - public void testCipherInputStream() { - byte[] data = new byte[] {-127, -100, -50, -10, -1, 0, 1, 10, 50, 127}; + public void testCipherInputStream() throws Exception { + byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; TestInputStream tis = new TestInputStream(data); CipherInputStream cis = new CipherInputStream(tis); - try { - for (int i=0; i expected) { - fail("The data returned by read(byte[] b) " - + "is larger than expected."); - } else { - ind = got; - got += cis.read(result); - } } - if (cis.read(result) != -1) { - fail("read(byte[] b) should return -1 " - + "at the end of the stream."); + if (got == expected) { + break; + } else if (got > expected) { + fail("The data returned by read(byte[] b) " + + "is larger than expected."); + } else { + ind = got; + got += cis.read(result); } - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); } + if (cis.read(result) != -1) { + fail("read(byte[] b) should return -1 " + + "at the end of the stream."); + } } /** * read(byte[] b, int off, int len) method testing. Tests that method - * returns the correct value (related to the InputStream), that it - * dicards bytes in the case of null buffer, and that it returns -1 at - * the end of stream. + * returns the correct value (related to the InputStream), that it dicards + * bytes in the case of null buffer, and that it returns -1 at the end of + * stream. */ - public void testRead3() { - byte[] data = new byte[] {-127, -100, -50, -10, -1, 0, 1, 10, 50, 127}; + public void testRead3() throws Exception { + byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; TestInputStream tis = new TestInputStream(data); CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - try { - int expected = data.length; - byte[] result = new byte[expected]; - int skip = 2; - int ind = skip; // index into the data array (to check the got data) - // should read and discard bytes; - cis.read(null, 0, skip); - int got = skip + cis.read(result, 0, 1); // the number of got bytes - while (true) { - for (int j=0; j expected) { - fail("The data returned by " - + "read(byte[] b, int off, int len) " - + "is larger than expected."); - } else { - ind = got; - got += cis.read(result, 0, 3); - } + int expected = data.length; + byte[] result = new byte[expected]; + + int skip = 2; + int ind = skip; // index into the data array (to check the got data) + // should read and discard bytes; + cis.read(null, 0, skip); + int got = skip + cis.read(result, 0, 1); // the number of got bytes + while (true) { + for (int j = 0; j < got - ind; j++) { + assertEquals("read(byte[] b, int off, int len) " + + "returned incorrect data.", result[j], data[ind + j]); } - if (cis.read(result, 0, 1) != -1) { - fail("read() should return -1 at the end of the stream."); + if (got == expected) { + break; + } else if (got > expected) { + fail("The data returned by " + + "read(byte[] b, int off, int len) " + + "is larger than expected."); + } else { + ind = got; + got += cis.read(result, 0, 3); } - } catch (NullPointerException e) { - e.printStackTrace(); - fail("Unexpected NullPointerException was thrown."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); } + if (cis.read(result, 0, 1) != -1) { + fail("read() should return -1 at the end of the stream."); + } } /** - * skip(long n) method testing. Tests that the method correctly skips - * the bytes. + * skip(long n) method testing. Tests that the method correctly skips the + * bytes. */ - public void testSkip() { - byte[] data = new byte[] {-127, -100, -50, -10, -1, 0, 1, 10, 50, 127}; + public void testSkip() throws Exception { + byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; TestInputStream tis = new TestInputStream(data); CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - try { - int expected = data.length; - byte[] result = new byte[expected]; + int expected = data.length; + byte[] result = new byte[expected]; - int skipped = (int) cis.skip(2); - int ind = skipped; - int got = skipped + cis.read(result, 0, 1); // the number of got bytes - while (true) { - for (int j=0; j expected) { - fail("The data returned by " - + "read(byte[] b, int off, int len) " - + "is larger than expected."); - } else { - ind = got; - got += cis.read(result, 0, 1); - } } - if ((got = cis.read(result, 0, 1)) != -1) { - fail("read() should return -1 at the end of the stream. " - + "Output is: " + got + "."); + if (got == expected) { + break; + } else if (got > expected) { + fail("The data returned by " + + "read(byte[] b, int off, int len) " + + "is larger than expected."); + } else { + ind = got; + got += cis.read(result, 0, 1); } - } catch (NullPointerException e) { - e.printStackTrace(); - fail("Unexpected NullPointerException was thrown."); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); } + if ((got = cis.read(result, 0, 1)) != -1) { + fail("read() should return -1 at the end of the stream. " + + "Output is: " + got + "."); + } } /** * available() method testing. Tests that the method always return 0. */ - public void testAvailable() { - byte[] data = new byte[] {-127, -100, -50, -10, -1, 0, 1, 10, 50, 127}; + public void testAvailable() throws Exception { + byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; TestInputStream tis = new TestInputStream(data); CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - try { - assertEquals("The returned by available() method value " - + "should be 0.", cis.available(), 0); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } + assertEquals("The returned by available() method value " + + "should be 0.", cis.available(), 0); } /** * close() method testing. Tests that the method calls the close() * method of the underlying input stream. */ - public void testClose() { - byte[] data = new byte[] {-127, -100, -50, -10, -1, 0, 1, 10, 50, 127}; + public void testClose() throws Exception { + byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; TestInputStream tis = new TestInputStream(data); CipherInputStream cis = new CipherInputStream(tis, new NullCipher()); - try { - cis.close(); - assertTrue("The close() method should call the close() method " - + "of its underlying input stream.", tis.wasClosed()); - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); - } + cis.close(); + assertTrue("The close() method should call the close() method " + + "of its underlying input stream.", tis.wasClosed()); } /** @@ -282,12 +242,5 @@ + "should be false.", cis.markSupported()); } - public static Test suite() { - return new TestSuite(CipherInputStreamTest.class); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } } Index: modules/crypto/src/test/api/java.injected/javax/crypto/CipherSpiTest.java =================================================================== --- modules/crypto/src/test/api/java.injected/javax/crypto/CipherSpiTest.java (revision 410067) +++ modules/crypto/src/test/api/java.injected/javax/crypto/CipherSpiTest.java (working copy) @@ -82,16 +82,12 @@ * Test for engineGetKeySize(Key) method * Assertion: It throws UnsupportedOperationException if it is not overriden */ - public void testCipherSpi02() { + public void testCipherSpi02() throws Exception { CipherSpi cSpi = new myCipherSpi(); try { cSpi.engineGetKeySize(null); assertTrue("UnsupportedOperationException must be thrown", false); } catch (UnsupportedOperationException e) { - } catch (Exception e) { - assertTrue( - "Unexpected ".concat(e.toString()).concat(" was thrown"), - false); } } @@ -99,16 +95,12 @@ * Test for engineWrap(Key) method * Assertion: It throws UnsupportedOperationException if it is not overriden */ - public void testCipherSpi03() { + public void testCipherSpi03() throws Exception { CipherSpi cSpi = new myCipherSpi(); try { cSpi.engineWrap(null); assertTrue("UnsupportedOperationException must be thrown", false); } catch (UnsupportedOperationException e) { - } catch (Exception e) { - assertTrue( - "Unexpected ".concat(e.toString()).concat(" was thrown"), - false); } } @@ -116,16 +108,12 @@ * Test for engineUnwrap(byte[], String, int) method * Assertion: It throws UnsupportedOperationException if it is not overriden */ - public void testCipherSpi04() { + public void testCipherSpi04() throws Exception { CipherSpi cSpi = new myCipherSpi(); try { cSpi.engineUnwrap(new byte[0], "", 0); assertTrue("UnsupportedOperationException must be thrown", false); } catch (UnsupportedOperationException e) { - } catch (Exception e) { - assertTrue( - "Unexpected ".concat(e.toString()).concat(" was thrown"), - false); } } @@ -224,10 +212,6 @@ bb2.position(0); assertTrue("Incorrect result", cSpi.engineDoFinal(bb1, bb2) > 0); } - - public static void main(String args[]) { - junit.textui.TestRunner.run(CipherSpiTest.class); - } } /** * Index: modules/crypto/src/test/api/java.injected/javax/crypto/CipherOutputStreamTest.java =================================================================== --- modules/crypto/src/test/api/java.injected/javax/crypto/CipherOutputStreamTest.java (revision 410067) +++ modules/crypto/src/test/api/java.injected/javax/crypto/CipherOutputStreamTest.java (working copy) @@ -52,146 +52,101 @@ * CipherOutputStream uses NullCipher if Cipher is not specified * in the constructor. */ - public void testCipherOutputStream() { - byte[] data = new byte[] {-127, -100, -50, -10, -1, 0, 1, 10, 50, 127}; + public void testCipherOutputStream() throws Exception { + byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; TestOutputStream tos = new TestOutputStream(); CipherOutputStream cos = new CipherOutputStream(tos); - - try { - cos.write(data); - cos.flush(); - byte[] result = tos.toByteArray(); - if (!Arrays.equals(result, data)) { - fail("NullCipher should be used " - + "if Cipher is not specified."); - } - } catch (IOException e) { - e.printStackTrace(); - fail("Unexpected IOException was thrown."); + cos.write(data); + cos.flush(); + byte[] result = tos.toByteArray(); + if (!Arrays.equals(result, data)) { + fail("NullCipher should be used " + "if Cipher is not specified."); } } /** - * write(int b) method testing. Tests that method writes correct values - * to the underlying output stream. + * write(int b) method testing. Tests that method writes correct values to + * the underlying output stream. */ - public void testWrite1() { - byte[] data = new byte[] {-127, -100, -50, -10, -1, 0, 1, 10, 50, 127}; + public void testWrite1() throws Exception { + byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 }; TestOutputStream tos = new TestOutputStream(); CipherOutputStream cos = new CipherOutputStream(tos, new NullCipher()); - - try { - for (int i=0; i - + @@ -93,6 +93,19 @@ + + + + + + + + + + + + + @@ -144,10 +157,26 @@ + + + + + + + + + + + + + + + + - +