diff options
author | Alex Klyubin <klyubin@google.com> | 2015-04-29 16:58:25 -0700 |
---|---|---|
committer | Alex Klyubin <klyubin@google.com> | 2015-04-29 17:03:41 -0700 |
commit | 227ad7426104de7c267c19712b3954e3ebe75140 (patch) | |
tree | 5fd0301efccb1da98bd64b42aca7d93c47dc3299 /luni | |
parent | 70be698e68966b8420ecb5873785351d7174f441 (diff) | |
download | libcore-227ad7426104de7c267c19712b3954e3ebe75140.zip libcore-227ad7426104de7c267c19712b3954e3ebe75140.tar.gz libcore-227ad7426104de7c267c19712b3954e3ebe75140.tar.bz2 |
Adjust MacTest for Bouncy Castle workaround.
AndroidKeyStore-backed Mac implementation is now offered by the
"AndroidKeyStoreBCWorkaround" provider (see
4812563f68c87278af68309662433279d10f573e). The test was changed
accordingly.
Moreover, this test was using a wrong way of detecting the
default provider for HMACs that can handle SecretKeySpec instances.
This is now fixed as well.
Bug: 20691708
Change-Id: I0b3a2d1ff6d968779419305978203ad64d703e99
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/test/java/org/apache/harmony/crypto/tests/javax/crypto/MacTest.java | 13 |
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; } |