summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2012-09-28 14:29:46 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-09-28 14:29:46 -0700
commit3db1bf0eedb0095f4e6aa1b24f3769058735024a (patch)
tree11f7b2a47680e5840a222a19f83fca9fe5286d4a /support
parent0df5a7ea6de1b66a1a27678e66909b85c1e464fe (diff)
parent67c7510f9ca84347ec029023b3f04832f4453b9f (diff)
downloadlibcore-3db1bf0eedb0095f4e6aa1b24f3769058735024a.zip
libcore-3db1bf0eedb0095f4e6aa1b24f3769058735024a.tar.gz
libcore-3db1bf0eedb0095f4e6aa1b24f3769058735024a.tar.bz2
am 67c7510f: am f776b18f: Merge "Add more CipherTest tests"
* commit '67c7510f9ca84347ec029023b3f04832f4453b9f': Add more CipherTest tests
Diffstat (limited to 'support')
-rw-r--r--support/src/test/java/libcore/java/security/StandardNames.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/support/src/test/java/libcore/java/security/StandardNames.java b/support/src/test/java/libcore/java/security/StandardNames.java
index dc57086..4211a10 100644
--- a/support/src/test/java/libcore/java/security/StandardNames.java
+++ b/support/src/test/java/libcore/java/security/StandardNames.java
@@ -85,6 +85,13 @@ public final class StandardNames extends Assert {
*/
public static final Map<String,Set<String>> PROVIDER_ALGORITHMS
= new HashMap<String,Set<String>>();
+
+ public static final Map<String,Set<String>> CIPHER_MODES
+ = new HashMap<String,Set<String>>();
+
+ public static final Map<String,Set<String>> CIPHER_PADDINGS
+ = new HashMap<String,Set<String>>();
+
private static void provide(String type, String algorithm) {
Set<String> algorithms = PROVIDER_ALGORITHMS.get(type);
if (algorithms == null) {
@@ -102,6 +109,22 @@ public final class StandardNames extends Assert {
assertNotNull(PROVIDER_ALGORITHMS.remove(type));
}
}
+ private static void provideCipherModes(String algorithm, String newModes[]) {
+ Set<String> modes = CIPHER_MODES.get(algorithm);
+ if (modes == null) {
+ modes = new HashSet<String>();
+ CIPHER_MODES.put(algorithm, modes);
+ }
+ modes.addAll(Arrays.asList(newModes));
+ }
+ private static void provideCipherPaddings(String algorithm, String newPaddings[]) {
+ Set<String> paddings = CIPHER_MODES.get(algorithm);
+ if (paddings == null) {
+ paddings = new HashSet<String>();
+ CIPHER_MODES.put(algorithm, paddings);
+ }
+ paddings.addAll(Arrays.asList(newPaddings));
+ }
static {
provide("AlgorithmParameterGenerator", "DSA");
provide("AlgorithmParameterGenerator", "DiffieHellman");
@@ -122,7 +145,10 @@ public final class StandardNames extends Assert {
provide("CertStore", "Collection");
provide("CertStore", "LDAP");
provide("CertificateFactory", "X.509");
+ // TODO: provideCipherModes and provideCipherPaddings for other Ciphers
provide("Cipher", "AES");
+ provideCipherModes("AES", new String[] { "CBC", "CFB", "CTR", "CTS", "ECB", "OFB" });
+ provideCipherPaddings("AES", new String[] { "NoPadding", "PKCS5Padding" });
provide("Cipher", "AESWrap");
provide("Cipher", "ARCFOUR");
provide("Cipher", "Blowfish");
@@ -848,4 +874,18 @@ public final class StandardNames extends Assert {
assertValidCipherSuites(CIPHER_SUITES, cipherSuites);
assertEquals(CIPHER_SUITES_DEFAULT, Arrays.asList(cipherSuites));
}
+
+ /**
+ * Get all supported mode names for the given cipher.
+ */
+ public static Set<String> getModesForCipher(String cipher) {
+ return CIPHER_MODES.get(cipher);
+ }
+
+ /**
+ * Get all supported padding names for the given cipher.
+ */
+ public static Set<String> getPaddingsForCipher(String cipher) {
+ return CIPHER_PADDINGS.get(cipher);
+ }
}