diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-18 17:39:42 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-18 17:39:42 -0700 |
commit | 7387da1059039afc7d8fd3e48e4d0712fff5dfaf (patch) | |
tree | 1637f1cfa85cbade78241ca9adc14dd4ddb3dd8d /crypto/src | |
parent | fa890109ecc4522f0e07481431c04d4cf6ba16d1 (diff) | |
download | libcore-7387da1059039afc7d8fd3e48e4d0712fff5dfaf.zip libcore-7387da1059039afc7d8fd3e48e4d0712fff5dfaf.tar.gz libcore-7387da1059039afc7d8fd3e48e4d0712fff5dfaf.tar.bz2 |
auto import from //branches/cupcake_rel/...@140373
Diffstat (limited to 'crypto/src')
13 files changed, 253 insertions, 255 deletions
diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java index 862cced..906057b 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/AllTests.java @@ -33,15 +33,15 @@ public class AllTests { TestSuite suite = new TestSuite("All tests for package org.apache.harmony.crypto.tests.javax.crypto.func;"); // $JUnit-BEGIN$ - suite.addTestSuite(CipherDesTest.class); suite.addTestSuite(CipherAesTest.class); suite.addTestSuite(CipherAesWrapTest.class); suite.addTestSuite(CipherDESedeTest.class); suite.addTestSuite(CipherDESedeWrapTest.class); + suite.addTestSuite(CipherDesTest.class); suite.addTestSuite(CipherPBETest.class); suite.addTestSuite(CipherRSATest.class); - suite.addTestSuite(KeyGeneratorFunctionalTest.class); suite.addTestSuite(KeyAgreementFunctionalTest.class); + suite.addTestSuite(KeyGeneratorFunctionalTest.class); suite.addTestSuite(MacFunctionalTest.class); suite.addTestSuite(SecretKeyFactoryFunctionalTest.class); diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java index ce62332..d00c62b 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesTest.java @@ -25,49 +25,53 @@ import targets.Cipher; @TestTargetClass(Cipher.AES.class) public class CipherAesTest extends TestCase { -// 76 cases checked +// 216 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_AesNoISO() { CipherSymmetricKeyThread aesNoISO = new CipherSymmetricKeyThread("AES", - new int[]{128},//Keysize must be equal to 128, 192, or 256. - new String[] {"ECB", "CBC", "CTR", "CTS", "CFB", "CFB8", - "CFB16", "CFB24", "CFB32", "CFB40", "CFB48", "CFB56", "CFB64", - "CFB72", "CFB80", "CFB88", "CFB96", "CFB104", "CFB112", "CFB120", - "CFB128", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", "OFB40", - "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", "OFB88", "OFB96", - "OFB104", "OFB112", "OFB120", "OFB128"}, - new String[]{"NoPadding", "PKCS5Padding"}); + new int[] {128, 192, 256}, // Keysize must be 128, 192, 256. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "CFB72", "CFB80", + "CFB88", "CFB96", "CFB104", "CFB112", "CFB120", + "CFB128", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", + "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", + "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", + "OFB128"}, new String[] {"NoPadding", "PKCS5Padding"}); aesNoISO.launcher(); - assertEquals(aesNoISO.getFailureMessages(), 0, aesNoISO.getTotalFailuresNumber()); + assertEquals(aesNoISO.getFailureMessages(), 0, aesNoISO + .getTotalFailuresNumber()); } -// 36 cases checked +// 108 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_AesISO() { CipherSymmetricKeyThread aesISO = new CipherSymmetricKeyThread("AES", - new int[]{128},//Keysize must be equal to 128, 192, or 256. - new String[] {"ECB", "CBC", "CFB", "CFB8", - "CFB16", "CFB24", "CFB32", "CFB40", "CFB48", "CFB56", "CFB64", - "CFB72", "CFB80", "CFB88", "CFB96", "CFB104", "CFB112", "CFB120", - "CFB128", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", "OFB40", - "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", "OFB88", "OFB96", - "OFB104", "OFB112", "OFB120", "OFB128"}, - new String[] {"ISO10126PADDING"}); + new int[] {128, 192, 256}, // Keysize must be 128, 192, 256. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "CFB72", "CFB80", + "CFB88", "CFB96", "CFB104", "CFB112", "CFB120", + "CFB128", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", + "OFB40", "OFB48", "OFB56", "OFB64", "OFB72", "OFB80", + "OFB88", "OFB96", "OFB104", "OFB112", "OFB120", + "OFB128"}, new String[] {"ISO10126PADDING"}); aesISO.launcher(); - assertEquals(aesISO.getFailureMessages(), 0, aesISO.getTotalFailuresNumber()); + assertEquals(aesISO.getFailureMessages(), 0, aesISO + .getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java index 2c75abd..d196edc 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherAesWrapTest.java @@ -25,32 +25,21 @@ import targets.Cipher; @TestTargetClass(Cipher.AESWrap.class) public class CipherAesWrapTest extends TestCase { -// one case checked. Mode "ECB" not supported. +// 3 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_AesWrap() { - CipherWrapThread aesWrap = new CipherWrapThread("AESWrap", - new int[]{128}, - new String[] {"ECB"}, - new String[] {"NoPadding"}); + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) + public void test_AesWrap() { + CipherWrapThread aesWrap = new CipherWrapThread("AESWrap", new int[] { + 128, 192, 256}, // Keysize must be 128, 192, 256. + new String[] {"ECB"}, new String[] {"NoPadding"}); aesWrap.launcher(); - - assertEquals(aesWrap.getFailureMessages(), 0, aesWrap.getTotalFailuresNumber()); - } - - public void test_AesWrap1() { - CipherWrapThread aesWrap = new CipherWrapThread("AES", - new int[]{128}, - new String[] {"ECB"}, - new String[] {"NoPadding"}); - aesWrap.launcher(); - - assertEquals(aesWrap.getFailureMessages(), 0, aesWrap.getTotalFailuresNumber()); + assertEquals(aesWrap.getFailureMessages(), 0, aesWrap + .getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java index c6053b6..7352e83 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeTest.java @@ -25,45 +25,47 @@ import targets.Cipher; @TestTargetClass(Cipher.DESede.class) public class CipherDESedeTest extends TestCase { -// 88 cases checked +// 80 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_DESedeNoISO() { - CipherSymmetricKeyThread DESedeNoISO = new CipherSymmetricKeyThread("DESede", - new int[]{112, 168},//Keysize must be equal to 112 or 168. - new String[] {"ECB", "CBC", "CTR", "CTS", "CFB", "CFB8", "CFB16", - "CFB24", "CFB32", "CFB40", "CFB48", "CFB56", "CFB64", "OFB", - "OFB8", "OFB16", "OFB24", "OFB32","OFB40", "OFB48", "OFB56", - "OFB64"}, - new String[]{"NoPadding", "PKCS5Padding"}); + CipherSymmetricKeyThread DESedeNoISO = new CipherSymmetricKeyThread( + "DESede", new int[] {112, 168},// Keysize must be 112 or 168. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", + "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", + "OFB64"}, new String[] {"NoPadding", "PKCS5Padding"}); DESedeNoISO.launcher(); - - assertEquals(DESedeNoISO.getFailureMessages(), 0, DESedeNoISO.getTotalFailuresNumber()); + + assertEquals(DESedeNoISO.getFailureMessages(), 0, DESedeNoISO + .getTotalFailuresNumber()); } -// 40 cases checked +// 40 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_DESedeISO() { - CipherSymmetricKeyThread DESedeISO = new CipherSymmetricKeyThread("DESede", - new int[]{112, 168},//Keysize must be equal to 112 or 168. - new String[] {"ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", - "CFB32", "CFB40", "CFB48", "CFB56", "CFB64", "OFB", - "OFB8", "OFB16", "OFB24", "OFB32","OFB40", "OFB48", - "OFB56", "OFB64"}, - new String[]{"ISO10126PADDING"}); + CipherSymmetricKeyThread DESedeISO = new CipherSymmetricKeyThread( + "DESede", new int[] {112, 168},// Keysize must be 112 or 168. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", + "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", + "OFB64"}, new String[] {"ISO10126PADDING"}); DESedeISO.launcher(); - - assertEquals(DESedeISO.getFailureMessages(), 0, DESedeISO.getTotalFailuresNumber()); + + assertEquals(DESedeISO.getFailureMessages(), 0, DESedeISO + .getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java index e2c9c9e..2169a93 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDESedeWrapTest.java @@ -25,21 +25,21 @@ import targets.Cipher; @TestTargetClass(Cipher.DESedeWrap.class) public class CipherDESedeWrapTest extends TestCase { -// 2 cases checked. Mode "CBC" not supported. +// 2 cases checked. @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_DESedeWrap() { CipherWrapThread DESedeWrap = new CipherWrapThread("DESedeWrap", - new int[]{112, 168}, - new String[] {"CBC"}, - new String[]{"NoPadding"}); + new int[] {112, 168}, // Keysize must be 112 or 168. + new String[] {"CBC"}, new String[] {"NoPadding"}); DESedeWrap.launcher(); - - assertEquals(DESedeWrap.getFailureMessages(), 0, DESedeWrap.getTotalFailuresNumber()); + + assertEquals(DESedeWrap.getFailureMessages(), 0, DESedeWrap + .getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java index 7b11ae9..6f8fbc3 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherDesTest.java @@ -25,45 +25,47 @@ import targets.Cipher; @TestTargetClass(Cipher.DES.class) public class CipherDesTest extends TestCase { -// 44 cases checked +// 40 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_DesNoISO() { CipherSymmetricKeyThread desNoISO = new CipherSymmetricKeyThread("DES", - new int[]{56},//Keysize must be equal to 56. - new String[] {"ECB", "CBC", "CTR", "CTS", "CFB", "CFB8", - "CFB16", "CFB24", "CFB32", "CFB40", "CFB48", "CFB56", - "CFB64", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", - "OFB40", "OFB48", "OFB56", "OFB64"}, - new String[]{"NoPadding", "PKCS5Padding"}); + new int[] {56},// Keysize must be 56. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", + "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", + "OFB64"}, new String[] {"NoPadding", "PKCS5Padding"}); desNoISO.launcher(); - - assertEquals(desNoISO.getFailureMessages(), 0, desNoISO.getTotalFailuresNumber()); + + assertEquals(desNoISO.getFailureMessages(), 0, desNoISO + .getTotalFailuresNumber()); } // 20 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_DesISO() { CipherSymmetricKeyThread desISO = new CipherSymmetricKeyThread("DES", - new int[]{56},//Keysize must be equal to 56. - new String[] {"ECB", "CBC", "CFB", "CFB8", - "CFB16", "CFB24", "CFB32", "CFB40", "CFB48", "CFB56", - "CFB64", "OFB", "OFB8", "OFB16", "OFB24", "OFB32", - "OFB40", "OFB48", "OFB56", "OFB64"}, - new String[]{"ISO10126PADDING"}); - + new int[] {56},// Keysize must be 56. + new String[] { + "ECB", "CBC", "CFB", "CFB8", "CFB16", "CFB24", "CFB32", + "CFB40", "CFB48", "CFB56", "CFB64", "OFB", "OFB8", + "OFB16", "OFB24", "OFB32", "OFB40", "OFB48", "OFB56", + "OFB64"}, new String[] {"ISO10126PADDING"}); + desISO.launcher(); - - assertEquals(desISO.getFailureMessages(), 0, desISO.getTotalFailuresNumber()); + + assertEquals(desISO.getFailureMessages(), 0, desISO + .getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java index a3fb3c2..3ea1f13 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherPBETest.java @@ -15,6 +15,7 @@ */ package org.apache.harmony.crypto.tests.javax.crypto.func; +import dalvik.annotation.AndroidOnly; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -25,75 +26,88 @@ import targets.Cipher; @TestTargetClass(Cipher.PBE.class) public class CipherPBETest extends TestCase { -// 2 cases checked + @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.PARTIAL_COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_PBEWithMD5AndDES() throws Exception { - CipherPBEThread PBEWithMD5AndDES = new CipherPBEThread("PBEWithMD5AndDES", - new int[]{40, 128}, - new String[] {"CBC"}, - new String[]{"PKCS5Padding"}); + CipherPBEThread PBEWithMD5AndDES = new CipherPBEThread( + "PBEWithMD5AndDES", new int[] {56}, new String[] {"CBC"}, + new String[] {"PKCS5Padding"}); PBEWithMD5AndDES.launcher(); - assertEquals(PBEWithMD5AndDES.getFailureMessages(), 0, PBEWithMD5AndDES.getTotalFailuresNumber()); + assertEquals(PBEWithMD5AndDES.getFailureMessages(), 0, PBEWithMD5AndDES + .getTotalFailuresNumber()); } -// 2 cases checked. Not supported on Android. @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_PBEWithSHA1AndDESede() throws Exception { - CipherPBEThread PBEWithSHA1AndDESede = new CipherPBEThread("PBEWithSHA1AndDESede", - new int[]{40, 128}, - new String[] {"CBC"}, - new String[]{"PKCS5Padding"}); + level = TestLevel.PARTIAL_COMPLETE, + notes = "", + method = "method", + args = {} + ) + @AndroidOnly("Not supported by RI (maybe with a different name)") + public void test_PBEWithSHAand3KeyTripleDES() throws Exception { + CipherPBEThread PBEWITHSHAAND3KEYTRIPLEDESCBC = new CipherPBEThread( + "PBEWITHSHAAND3-KEYTRIPLEDES-CBC", new int[] {112, 168}, + new String[] {"CBC"}, new String[] {"PKCS5Padding"}); - PBEWithSHA1AndDESede.launcher(); + PBEWITHSHAAND3KEYTRIPLEDESCBC.launcher(); - assertEquals(PBEWithSHA1AndDESede.getFailureMessages(), 0, PBEWithSHA1AndDESede.getTotalFailuresNumber()); + assertEquals(PBEWITHSHAAND3KEYTRIPLEDESCBC.getFailureMessages(), 0, + PBEWITHSHAAND3KEYTRIPLEDESCBC.getTotalFailuresNumber()); } -// 2 cases checked. Not supported on Android. - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_PBEWithSHA1AndRC2_40() throws Exception { - CipherPBEThread PBEWithSHA1AndRC2_40 = new CipherPBEThread("PBEWithSHA1AndRC2_40", - new int[]{40, 128}, - new String[] {"CBC"}, - new String[]{"PKCS5Padding"}); + // Supported, but not part of mandatory components for Android + public void disabled_test_PBEWithSHA1And40BitRC2() throws Exception { + CipherPBEThread PBEWithSHA1AndRC2_40 = new CipherPBEThread( + "PBEWITHSHAAND40BITRC2-CBC", new int[] {40}, + new String[] {"CBC"}, new String[] {"PKCS5Padding"}); PBEWithSHA1AndRC2_40.launcher(); - assertEquals(PBEWithSHA1AndRC2_40.getFailureMessages(), 0, PBEWithSHA1AndRC2_40.getTotalFailuresNumber()); + assertEquals(PBEWithSHA1AndRC2_40.getFailureMessages(), 0, + PBEWithSHA1AndRC2_40.getTotalFailuresNumber()); } -// Key factory does not supported. - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_PBEWITHSHAAND3() throws Exception { - CipherPBEThread PBEWithSHA1AndRC2_40 = new CipherPBEThread("PBEWITHSHAAND3", - new int[]{40, 128}, - new String[] {"CBC"}, - new String[]{"NoPadding", "PKCS5Padding", "ISO10126PADDING"}); + + // Not supported by Android + public void disabled_test_PBEWithMD5AndTripleDES() throws Exception { + CipherPBEThread PBEWithMD5AndTripleDES = new CipherPBEThread( + "PBEWithMD5AndTripleDES", new int[] {112, 168}, + new String[] {"CBC"}, new String[] {"PKCS5Padding"}); + + PBEWithMD5AndTripleDES.launcher(); + + assertEquals(PBEWithMD5AndTripleDES.getFailureMessages(), 0, + PBEWithMD5AndTripleDES.getTotalFailuresNumber()); + } + + // Not supported by Android + public void disabled_test_PBEWithSHA1AndDESede() throws Exception { + CipherPBEThread PBEWithSHA1AndDESede = new CipherPBEThread( + "PBEWithSHA1AndDESede", new int[] {112, 168}, + new String[] {"CBC"}, new String[] {"PKCS5Padding"}); + + PBEWithSHA1AndDESede.launcher(); + + assertEquals(PBEWithSHA1AndDESede.getFailureMessages(), 0, + PBEWithSHA1AndDESede.getTotalFailuresNumber()); + } + + // Not supported by Android + public void disabled_test_PBEWithSHA1AndRC2_40() throws Exception { + CipherPBEThread PBEWithSHA1AndRC2_40 = new CipherPBEThread( + "PBEWithSHA1AndRC2_40", new int[] {40}, new String[] {"CBC"}, + new String[] {"PKCS5Padding"}); PBEWithSHA1AndRC2_40.launcher(); - assertEquals(PBEWithSHA1AndRC2_40.getFailureMessages(), 0, PBEWithSHA1AndRC2_40.getTotalFailuresNumber()); + assertEquals(PBEWithSHA1AndRC2_40.getFailureMessages(), 0, + PBEWithSHA1AndRC2_40.getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java index 90cb956..5acc5b5 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherRSATest.java @@ -15,6 +15,7 @@ */ package org.apache.harmony.crypto.tests.javax.crypto.func; +import dalvik.annotation.AndroidOnly; import dalvik.annotation.TestLevel; import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; @@ -25,74 +26,60 @@ import targets.Cipher; @TestTargetClass(Cipher.RSA.class) public class CipherRSATest extends TestCase { -// 3 cases checked +// 3 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) public void test_RSAShortKey() { - CipherRSAThread rsa = new CipherRSAThread("RSA", - new int[]{512}, - new String[] {"ECB"}, - new String[]{"PKCS1Padding", - "OAEPWITHMD5ANDMGF1Padding", "OAEPWITHSHA1ANDMGF1Padding"}); + CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {512}, + new String[] {"ECB"}, new String[] { + "PKCS1PADDING", "OAEPWITHMD5ANDMGF1PADDING", + "OAEPWITHSHA1ANDMGF1PADDING"}); rsa.launcher(); - + assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); } - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_RSALongKey() { - CipherRSAThread rsa = new CipherRSAThread("RSA", - new int[]{1024}, + // Not supported by Android + public void disabled_test_RSALongKey() { + CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {1024}, new String[] {"ECB"}, - new String[]{"OAEPWITHSHA-384ANDMGF1Padding"}); + new String[] {"OAEPWITHSHA-384ANDMGF1PADDING", + "OAEPWITHSHA-256ANDMGF1PADDING"}); rsa.launcher(); - + assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); } - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) - public void _test_RSAXXXLKey() { - CipherRSAThread rsa = new CipherRSAThread("RSA", - new int[]{2048}, + // Not supported by Android + public void disabled_test_RSAXXXLKey() { + CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {2048}, new String[] {"ECB"}, - new String[]{"OAEPWITHSHA-512ANDMGF1Padding"}); + new String[] {"OAEPWITHSHA-512ANDMGF1PADDING"}); rsa.launcher(); - + assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); } -// 2 cases checked @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "method", - args = {} - ) + level = TestLevel.COMPLETE, + notes = "", + method = "method", + args = {} + ) + @AndroidOnly("Fails on RI but succeeds on Android.") public void test_RSANoPadding() { - CipherRSAThread rsa = new CipherRSAThread("RSA", - new int[]{512}, - new String[] {"ECB"}, - new String[]{"NoPadding", "ISO9796-1PADDING"}); + CipherRSAThread rsa = new CipherRSAThread("RSA", new int[] {1024}, + new String[] {"ECB"}, new String[] {"NOPADDING"}); rsa.launcher(); - + assertEquals(rsa.getFailureMessages(), 0, rsa.getTotalFailuresNumber()); } } diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java index 2b34c1c..b0eabe2 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/CipherWrapThread.java @@ -33,8 +33,8 @@ public class CipherWrapThread extends CipherThread { kg.init(getKeyLength(), new SecureRandom()); Key key = kg.generateKey(); - Cipher cip = Cipher.getInstance(getAlgName() + "/" + getMode() + "/" + - getPadding()); + // ignore mode and padding + Cipher cip = Cipher.getInstance(getAlgName()); cip.init(Cipher.WRAP_MODE, key); byte[] output = cip.wrap(key); diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java index d0e5f6a..e706c77 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyAgreementFunctionalTest.java @@ -16,21 +16,23 @@ package org.apache.harmony.crypto.tests.javax.crypto.func; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; +import dalvik.annotation.TestTargets; import junit.framework.TestCase; import targets.KeyAgreement; -@TestTargetClass(KeyAgreement.DH.class) public class KeyAgreementFunctionalTest extends TestCase { - @TestTargetNew( + @TestTargets({ + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", + clazz = KeyAgreement.DH.class, method = "method", args = {} ) + }) public void test_KeyAgreement() throws Exception { String[] algArray = {"DES", "DESede"}; diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java index dde6fbd..50b6ef6 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/KeyGeneratorFunctionalTest.java @@ -16,7 +16,6 @@ package org.apache.harmony.crypto.tests.javax.crypto.func; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargets; @@ -24,66 +23,67 @@ import junit.framework.TestCase; import targets.KeyGenerator; -@TestTargetClass(KeyGenerator.AES.class) public class KeyGeneratorFunctionalTest extends TestCase { -@TestTargets({ - @TestTargetNew( + @TestTargets({ + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", + clazz = KeyGenerator.AES.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.DES.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.DESede.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.HMACMD5.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.HMACSHA1.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.HMACSHA256.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.HMACSHA384.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = KeyGenerator.HMACSHA512.class, method = "method", args = {} - )}) + ) + }) public void test_() throws Exception { - String[] algArray = {/*"DH",*/ "AES", "DES", "DESEDE", "DESede", + String[] algArray = {"AES", "DES", "DESEDE", "DESede", "HMACMD5", "HmacMD5", "HMACSHA1", "HmacSHA1", "HMACSHA256", "HmacSHA256", "HMACSHA384", "HmacSHA384", "HMACSHA512", "HmacSHA512"}; diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java index bfe486a..6452cb4 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/MacFunctionalTest.java @@ -16,7 +16,6 @@ package org.apache.harmony.crypto.tests.javax.crypto.func; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargets; @@ -24,44 +23,44 @@ import junit.framework.TestCase; import targets.Mac; -@TestTargetClass(Mac.HMACMD5.class) public class MacFunctionalTest extends TestCase { -@TestTargets({ - @TestTargetNew( + @TestTargets({ + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", + clazz = Mac.HMACMD5.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = Mac.HMACSHA1.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = Mac.HMACSHA256.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = Mac.HMACSHA384.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = Mac.HMACSHA512.class, method = "method", args = {} ) -}) + }) public void test_Mac() throws Exception { String[] algArray = {"HMACSHA1", "HMACSHA256", "HMACSHA384", "HMACSHA512", "HMACMD5"}; diff --git a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java index 286bb5b..35fb490 100644 --- a/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java +++ b/crypto/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/func/SecretKeyFactoryFunctionalTest.java @@ -15,8 +15,8 @@ */ package org.apache.harmony.crypto.tests.javax.crypto.func; +import dalvik.annotation.KnownFailure; import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetClass; import dalvik.annotation.TestTargetNew; import dalvik.annotation.TestTargets; @@ -24,33 +24,32 @@ import junit.framework.TestCase; import targets.SecretKeyFactory; -@TestTargetClass(SecretKeyFactory.DES.class) public class SecretKeyFactoryFunctionalTest extends TestCase { -@TestTargets({ - @TestTargetNew( + @TestTargets({ + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", + clazz = SecretKeyFactory.DES.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = SecretKeyFactory.DESede.class, method = "method", args = {} ), - @TestTargetNew( + @TestTargetNew( level = TestLevel.COMPLETE, notes = "", clazz = SecretKeyFactory.PBEWITHMD5ANDDES.class, method = "method", args = {} ) -}) + }) public void test_() throws Exception { - String[] algArray = {"DES", "DESede", "PBEWITHMD5ANDDES", - "PBEWithSHA1AndDESede", "PBEWithSHA1AndRC2_40"}; + String[] algArray = {"DES", "DESede", "PBEWITHMD5ANDDES"}; SecretKeyFactoryThread skft = new SecretKeyFactoryThread(algArray); skft.launcher(); |