Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 71551 invoked from network); 26 Apr 2006 09:17:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Apr 2006 09:17:40 -0000 Received: (qmail 77798 invoked by uid 500); 26 Apr 2006 09:17:40 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 77769 invoked by uid 500); 26 Apr 2006 09:17:40 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 77758 invoked by uid 99); 26 Apr 2006 09:17:40 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Apr 2006 02:17:40 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 26 Apr 2006 02:17:39 -0700 Received: (qmail 71397 invoked by uid 65534); 26 Apr 2006 09:17:18 -0000 Message-ID: <20060426091718.71396.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r397154 - /incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java Date: Wed, 26 Apr 2006 09:17:18 -0000 To: harmony-commits@incubator.apache.org From: smishura@apache.org X-Mailer: svnmailer-1.0.8 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: smishura Date: Wed Apr 26 02:17:16 2006 New Revision: 397154 URL: http://svn.apache.org/viewcvs?rev=397154&view=rev Log: Ajusting indent to 4 spaces Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java?rev=397154&r1=397153&r2=397154&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java Wed Apr 26 02:17:16 2006 @@ -36,23 +36,23 @@ public class CipherTest extends junit.framework.TestCase { - /** - * @tests javax.crypto.Cipher#getInstance(java.lang.String) - */ + /** + * @tests javax.crypto.Cipher#getInstance(java.lang.String) + */ public void test_getInstanceLjava_lang_String() throws Exception { Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding"); assertNotNull("Received a null Cipher instance", cipher); } - /** - * @tests javax.crypto.Cipher#getInstance(java.lang.String, - * java.lang.String) - */ - public void test_getInstanceLjava_lang_StringLjava_lang_String() + /** + * @tests javax.crypto.Cipher#getInstance(java.lang.String, + * java.lang.String) + */ + public void test_getInstanceLjava_lang_StringLjava_lang_String() throws Exception { Provider[] providers = Security.getProviders("Cipher.DES"); - + assertNotNull("No installed providers support Cipher.DES", providers); for (int i = 0; i < providers.length; i++) { @@ -83,12 +83,12 @@ } catch (NoSuchProviderException e) { // Expected } - } + } - /** - * @tests javax.crypto.Cipher#getInstance(java.lang.String, - * java.security.Provider) - */ + /** + * @tests javax.crypto.Cipher#getInstance(java.lang.String, + * java.security.Provider) + */ public void test_getInstanceLjava_lang_StringLjava_security_Provider() throws Exception { @@ -102,9 +102,9 @@ } } - /** - * @tests javax.crypto.Cipher#getProvider() - */ + /** + * @tests javax.crypto.Cipher#getProvider() + */ public void test_getProvider() throws Exception { Provider[] providers = Security.getProviders("Cipher.AES"); @@ -121,9 +121,9 @@ } } - /** - * @tests javax.crypto.Cipher#getAlgorithm() - */ + /** + * @tests javax.crypto.Cipher#getAlgorithm() + */ public void test_getAlgorithm() throws Exception { final String algorithm = "DESede/CBC/PKCS5Padding"; @@ -132,9 +132,9 @@ .equals(algorithm)); } - /** - * @tests javax.crypto.Cipher#getBlockSize() - */ + /** + * @tests javax.crypto.Cipher#getBlockSize() + */ public void test_getBlockSize() throws Exception { final String algorithm = "DESede/CBC/PKCS5Padding"; @@ -142,9 +142,9 @@ assertEquals("Block size does not match", 8, cipher.getBlockSize()); } - /** - * @tests javax.crypto.Cipher#getOutputSize(int) - */ + /** + * @tests javax.crypto.Cipher#getOutputSize(int) + */ public void test_getOutputSizeI() throws Exception { final String algorithm = "DESede"; final int keyLen = 168; @@ -169,11 +169,11 @@ assertTrue("Output size too small", result > 15); } - /** - * @tests javax.crypto.Cipher#getIV() - * @tests javax.crypto.Cipher#init(int, java.security.Key, - * java.security.AlgorithmParameters) - */ + /** + * @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: @@ -206,11 +206,11 @@ 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) - */ + /** + * @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 { /* @@ -247,9 +247,9 @@ cipherParmsEnc)); } - /** - * @tests javax.crypto.Cipher#init(int, java.security.Key) - */ + /** + * @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; @@ -266,10 +266,10 @@ cipher.init(Cipher.ENCRYPT_MODE, cipherKey); } - /** - * @tests javax.crypto.Cipher#init(int, java.security.Key, - * java.security.SecureRandom) - */ + /** + * @tests javax.crypto.Cipher#init(int, java.security.Key, + * java.security.SecureRandom) + */ public void test_initILjava_security_KeyLjava_security_SecureRandom() throws Exception { @@ -289,10 +289,10 @@ cipher.init(Cipher.ENCRYPT_MODE, cipherKey, sr); } - /** - * @tests javax.crypto.Cipher#init(int, java.security.Key, - * java.security.spec.AlgorithmParameterSpec) - */ + /** + * @tests javax.crypto.Cipher#init(int, java.security.Key, + * java.security.spec.AlgorithmParameterSpec) + */ public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpec() throws Exception { @@ -323,12 +323,12 @@ assertTrue("IVs differ", Arrays.equals(cipherIV, iv)); } - /** - * @tests javax.crypto.Cipher#init(int, java.security.Key, - * java.security.spec.AlgorithmParameterSpec, - * java.security.SecureRandom) - */ - public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom() + /** + * @tests javax.crypto.Cipher#init(int, java.security.Key, + * java.security.spec.AlgorithmParameterSpec, + * java.security.SecureRandom) + */ + public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom() throws Exception { final String algorithm = "DESede"; final int keyLen = 168; @@ -357,118 +357,118 @@ assertTrue("IVs differ", Arrays.equals(cipherIV, iv)); } - /** - * @tests javax.crypto.Cipher#update(byte[], int, int) - */ - public void test_update$BII() throws Exception { - for (int index = 1; index < 4; index++) { - Cipher c = Cipher.getInstance("DESEDE/CBC/PKCS5Padding"); - - byte[] keyMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" - + index + ".key"); - DESedeKeySpec keySpec = new DESedeKeySpec(keyMaterial); - SecretKeyFactory skf = SecretKeyFactory.getInstance("DESEDE"); - Key k = skf.generateSecret(keySpec); - - byte[] ivMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" - + index + ".iv"); - IvParameterSpec iv = new IvParameterSpec(ivMaterial); - - c.init(Cipher.DECRYPT_MODE, k, iv); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] input = new byte[256]; - String resPath = "hyts_" + "des-ede3-cbc.test" + index - + ".ciphertext"; - InputStream is = getStream(resPath); - - int bytesRead = is.read(input, 0, 256); - while (bytesRead > 0) { - byte[] output = c.update(input, 0, bytesRead); - if (output != null) { - baos.write(output); - } - bytesRead = is.read(input, 0, 256); - } - - byte[] output = c.doFinal(); - if (output != null) { - baos.write(output); - } + /** + * @tests javax.crypto.Cipher#update(byte[], int, int) + */ + public void test_update$BII() throws Exception { + for (int index = 1; index < 4; index++) { + Cipher c = Cipher.getInstance("DESEDE/CBC/PKCS5Padding"); + + byte[] keyMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" + + index + ".key"); + DESedeKeySpec keySpec = new DESedeKeySpec(keyMaterial); + SecretKeyFactory skf = SecretKeyFactory.getInstance("DESEDE"); + Key k = skf.generateSecret(keySpec); + + byte[] ivMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" + index + + ".iv"); + IvParameterSpec iv = new IvParameterSpec(ivMaterial); + + c.init(Cipher.DECRYPT_MODE, k, iv); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] input = new byte[256]; + String resPath = "hyts_" + "des-ede3-cbc.test" + index + + ".ciphertext"; + InputStream is = getStream(resPath); + + int bytesRead = is.read(input, 0, 256); + while (bytesRead > 0) { + byte[] output = c.update(input, 0, bytesRead); + if (output != null) { + baos.write(output); + } + bytesRead = is.read(input, 0, 256); + } - byte[] decipheredCipherText = baos.toByteArray(); - is.close(); + byte[] output = c.doFinal(); + if (output != null) { + baos.write(output); + } - byte[] plaintextBytes = loadBytes("hyts_" + "des-ede3-cbc.test" - + index + ".plaintext"); + byte[] decipheredCipherText = baos.toByteArray(); + is.close(); + + byte[] plaintextBytes = loadBytes("hyts_" + "des-ede3-cbc.test" + + index + ".plaintext"); assertTrue("Operation produced incorrect results", Arrays.equals( plaintextBytes, decipheredCipherText)); - }// end for - } + }// end for + } - /** - * @tests javax.crypto.Cipher#doFinal() - */ - public void test_doFinal() throws Exception { - for (int index = 1; index < 4; index++) { - Cipher c = Cipher.getInstance("DESEDE/CBC/PKCS5Padding"); - - byte[] keyMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" - + index + ".key"); - DESedeKeySpec keySpec = new DESedeKeySpec(keyMaterial); - SecretKeyFactory skf = SecretKeyFactory.getInstance("DESEDE"); - Key k = skf.generateSecret(keySpec); - - byte[] ivMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" - + index + ".iv"); - IvParameterSpec iv = new IvParameterSpec(ivMaterial); - - c.init(Cipher.ENCRYPT_MODE, k, iv); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] input = new byte[256]; - String resPath = "hyts_" + "des-ede3-cbc.test" + index - + ".plaintext"; - InputStream is = getStream(resPath); - - int bytesRead = is.read(input, 0, 256); - while (bytesRead > 0) { - byte[] output = c.update(input, 0, bytesRead); - if (output != null) { - baos.write(output); - } - bytesRead = is.read(input, 0, 256); - } - byte[] output = c.doFinal(); - if (output != null) { - baos.write(output); - } - byte[] encryptedPlaintext = baos.toByteArray(); - is.close(); + /** + * @tests javax.crypto.Cipher#doFinal() + */ + public void test_doFinal() throws Exception { + for (int index = 1; index < 4; index++) { + Cipher c = Cipher.getInstance("DESEDE/CBC/PKCS5Padding"); + + byte[] keyMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" + + index + ".key"); + DESedeKeySpec keySpec = new DESedeKeySpec(keyMaterial); + SecretKeyFactory skf = SecretKeyFactory.getInstance("DESEDE"); + Key k = skf.generateSecret(keySpec); + + byte[] ivMaterial = loadBytes("hyts_" + "des-ede3-cbc.test" + index + + ".iv"); + IvParameterSpec iv = new IvParameterSpec(ivMaterial); + + c.init(Cipher.ENCRYPT_MODE, k, iv); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] input = new byte[256]; + String resPath = "hyts_" + "des-ede3-cbc.test" + index + + ".plaintext"; + InputStream is = getStream(resPath); + + int bytesRead = is.read(input, 0, 256); + while (bytesRead > 0) { + byte[] output = c.update(input, 0, bytesRead); + if (output != null) { + baos.write(output); + } + bytesRead = is.read(input, 0, 256); + } + byte[] output = c.doFinal(); + if (output != null) { + baos.write(output); + } + byte[] encryptedPlaintext = baos.toByteArray(); + is.close(); - byte[] cipherText = loadBytes("hyts_" + "des-ede3-cbc.test" - + index + ".ciphertext"); + byte[] cipherText = loadBytes("hyts_" + "des-ede3-cbc.test" + index + + ".ciphertext"); assertTrue("Operation produced incorrect results", Arrays.equals( encryptedPlaintext, cipherText)); - }// end for - } + }// end for + } + + private byte[] loadBytes(String resPath) { + try { + InputStream is = getStream(resPath); - private byte[] loadBytes(String resPath) { - try { - InputStream is = getStream(resPath); - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - byte[] buff = new byte[1024]; - int readlen; - while ((readlen = is.read(buff)) > 0) { - out.write(buff, 0, readlen); - } - is.close(); - return out.toByteArray(); - } catch (IOException e) { - return null; - } - } + ByteArrayOutputStream out = new ByteArrayOutputStream(); + byte[] buff = new byte[1024]; + int readlen; + while ((readlen = is.read(buff)) > 0) { + out.write(buff, 0, readlen); + } + is.close(); + return out.toByteArray(); + } catch (IOException e) { + return null; + } + } public InputStream getStream(String name) {