summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorAlex Klyubin <klyubin@google.com>2015-04-30 16:12:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-30 16:12:45 +0000
commit1bc6f080c77deb3cc53d55ec60c98167ea093911 (patch)
tree7561d69e9ecd1d3aeba6bae3c54b909e1fef7f79 /luni
parent3bb833819dba8d530620ad6d43dc53c3fd54763b (diff)
parent227ad7426104de7c267c19712b3954e3ebe75140 (diff)
downloadlibcore-1bc6f080c77deb3cc53d55ec60c98167ea093911.zip
libcore-1bc6f080c77deb3cc53d55ec60c98167ea093911.tar.gz
libcore-1bc6f080c77deb3cc53d55ec60c98167ea093911.tar.bz2
Merge "Adjust MacTest for Bouncy Castle workaround." into mnc-dev
Diffstat (limited to 'luni')
-rw-r--r--luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java b/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java
index e90452d..48d945b 100644
--- a/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java
+++ b/luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java
@@ -76,8 +76,13 @@ public class MacTest extends TestCase {
static {
for (int i = 0; i < validAlgorithmsMac.length; i++) {
- defaultProvider = SpiEngUtils.isSupport(validAlgorithmsMac[i],
- srvMac);
+ try {
+ Mac mac = Mac.getInstance(validAlgorithmsMac[i]);
+ mac.init(new SecretKeySpec(new byte[64], validAlgorithmsMac[i]));
+ defaultProvider = mac.getProvider();
+ } catch (NoSuchAlgorithmException ignored) {
+ } catch (InvalidKeyException ignored) {}
+
DEFSupported = (defaultProvider != null);
if (DEFSupported) {
defaultAlgorithm = validAlgorithmsMac[i];
@@ -103,7 +108,7 @@ public class MacTest extends TestCase {
// Do not test AndroidKeyStore's Mac. It cannot be initialized without providing an
// AndroidKeyStore-backed SecretKey instance. It's OKish not to test here because it's
// tested by cts/tests/test/keystore.
- if ("AndroidKeyStore".equals(p.getName())) {
+ if (p.getName().startsWith("AndroidKeyStore")) {
continue;
}
macList.add(Mac.getInstance(defaultAlgorithm, p));
@@ -854,7 +859,7 @@ public class MacTest extends TestCase {
// Do not test AndroidKeyStore's Mac. It cannot be initialized without providing an
// AndroidKeyStore-backed SecretKey instance. It's OKish not to test here because it's
// tested by cts/tests/test/keystore.
- if ("AndroidKeyStore".equals(providers[i].getName())) {
+ if (providers[i].getName().startsWith("AndroidKeyStore")) {
continue;
}