1

I follow the next tutorial for get the OpenSSL Fips in my app https://wiki.openssl.org/index.php/FIPS_Library_and_Android now I can import the library to my project and link it, but I need to create a wrapper class for connect my library with my Java code, my question is... is there a way to achieve this in a easy way? There are a lot of methods inside the OpenSSL library and i need to read the documentation of all of them and create a function in C for each one, and I don't have experience in C, so if you know another way to do this i'll appreciate your help.

alan10fm
  • 239
  • 2
  • 6

1 Answers1

0

I need to create a wrapper class for connect my library with my Java code, my question is... is there a way to achieve this in a easy way?

The easiest way is to create the wrapper shared object. The wrapper shared object will link to the static version of the OpenSSL library and hide all its symbols. To hide the symbols, be sure to specify the option -Wl,--exclude-libs,all.

If you were working from the command line (and not a Java activity started from Zygote), then you could just use LD_PRELOAD tricks. But you have to work around Zygote loading the down level version of the library.


read the documentation of all of them...

Yep, there's no way around RTFM :)


and create a function in C for each one...

No, you don't need to export 1 to 1. For example, your wrapper can just export a function like:

MY_SSL_CTX* MyCreateClientContext(...);

MY_SSL_CTX would effectively wrap OpenSSL's SSL_CTX. But MyCreateClientContext would aggregate different functions calls. For example, it would likely call:

  • SSLv23_method
  • SSL_CTX_new
  • SSL_CTX_set_verify
  • SSL_CTX_set_options
  • SSL_CTX_load_verify_locations

You can see an example of what I would expect it to call in OpenSSL's SSL/TLS Client example. That would include configuring context options, like SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION.

Community
  • 1
  • 1
jww
  • 97,681
  • 90
  • 411
  • 885