Reputation: 1
I've been trying to build XML documents using the javax.xml.crypto.dsig.XMLSignatureFactory library. When instantiating the class, I need to pass a security provider as the argument of the getInstance() function, i.e.
XMLSignatureFactory.getInstance("DOM", provider)
Now, normally, the provider would be found in the apache santuario library i.e. XMLDSigRI():
private val xmlSigFactory = XMLSignatureFactory.getInstance("DOM", org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI())
However, the library is using the java.util.Base64 class, which doesn't work for Android API Version < 26.
I have tried using the BouncyCastle security provider, which does not work for whatever reason, since I am getting this error when trying to run it:
Caused by: javax.xml.crypto.NoSuchMechanismException: no such mechanism type: DOM for provider BC
And the same for SpongyCastle. (provider SC)
Is there any way to find a working security provider for Android API Version >= 24? If not, what could be the possible workaround here?
Tried using every single one of the listed security providers which I got with this chunk:
for(p in Security.getProviders()) {
Log.d("PROVIDER NAME", p.name)
Log.d("PROVIDER INFO", p.info)
}
BouncyCastle and SpongyCastle included. Tried forking and changing the whole library so that the java.util.Base64 class gets replaced with another Base64 class, which proved difficult and I gave up on it(for now). Trying to find a normal security provider which works with API < 26
Upvotes: 0
Views: 142