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
1 file changed