summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2016-10-31 09:40:11 -0700
committerKenny Root <kroot@google.com>2016-11-04 19:29:40 +0000
commita1d3063e3f0d9b8eb9b049bcaa0808f4ea6fba64 (patch)
tree520380d7d1e6a05606c614811962130f38432487 /support
parent6facd9d7eb3b76137a5e32949bf29f91d3b9f4f9 (diff)
Make sure BouncyCastleProvider is initialized
When running these tests against an Android system when we're not built as part of the system image (e.g., we have our own BouncyCastleProvider instance), then we need to make sure our instance of BouncyCastleProvider is initialized properly. The initialization happens in its constructor. In TestKeyStore the included version of BouncyCastleProvider does not need to be inserted as a security provider since it's only used to create X.509 certificates. However, BouncyCastle calls into itself for some things like OID -> key type conversion. This relies on all of its internal data structures being initialized properly. In particular there is a keyInfoConverters field that must be populated to work correctly. If keyInfoConverters is not populated, the generated certificate will have a null PublicKey since it can't figure out what type of key it is. Test: ran outside of CTS Test: cts-tradefed run cts -m CtsLibcoreTestCases -a arm64-v8a Bug: 31119038 Change-Id: I1bcc73a363cb9dac9e9decb9046d386d3394f1d9
Diffstat (limited to 'support')
-rw-r--r--support/src/test/java/libcore/java/security/TestKeyStore.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/support/src/test/java/libcore/java/security/TestKeyStore.java b/support/src/test/java/libcore/java/security/TestKeyStore.java
index 2313a74a06..e537268450 100644
--- a/support/src/test/java/libcore/java/security/TestKeyStore.java
+++ b/support/src/test/java/libcore/java/security/TestKeyStore.java
@@ -145,6 +145,11 @@ public final class TestKeyStore extends Assert {
// algorithm come from the default providers
Security.insertProviderAt(new BouncyCastleProvider(),
Security.getProviders().length+1);
+ } else if (!BouncyCastleProvider.class.getName().startsWith("com.android")) {
+ // If we run outside of the Android system, we need to make sure
+ // that the BouncyCastleProvider's static field keyInfoConverters
+ // is initialized. This happens in the default constructor only.
+ new BouncyCastleProvider();
}
}