I figured it out. All you have to do is to use Bouncy Castle javaJava library. All other libraries are absolute, utter garbage.
None of the libraries have docs, but hey, at least this one is not a goddamn binding to a 30 year oldthirty-year-old C code.