Fix X509CertificateTest.testVerifyPublicKeyString failure.

The test was failing because it was making the wrong assumption that
JCA's Signature implementation will select the implementation from the
highest priority provider which offers the matching signature
algorithm. This assumption is wrong because it does not take into
consideration that JCA also filters providers using
SupportedKeyClasses and SupportedKeyFormats attributes.

In this particular case, AndroidKeyStore Provider happens to be the
highest priority Provider which offers Signature.MD5withRSA. However,
according to its declaration, it offers that only for public keys
which are instances of AndroidKeyStorePublicKey.

The fix is to rely on JCA's Signature implementation selection
mechanism to find the highest priority provider which supports the
desired public key.

Bug: 21735869
Change-Id: Ie40f8a1cbf898966614a290c2d6cfe8350a1e99f
1 file changed