How to use OpenSSL with Android?

I have a project to use OpenSSL in Android application. I am just a bit confused about this lib. I read that OpenSSL already exists on Android... Is this true ? If so, how do I use it...

If it does not, does this mean that I have to build or get the lib from somewhere... If I need to do that, does anyone know where I can find it, and how I would go about building for use with Android?

Can someone help me to understand what I need to get started... Please don't be afraid to give lot of details. :)

Thanks in advance !

UPDATE: What I want to do is:

  • Create the keypair
  • Get private key
  • Get public key
  • Encrypt a text
  • Decrypt the text (from another location)

I am using Mac OSX with Eclipse.

Answers


I read that OpenSSL already exists on Android... Is this true ? If so, how do I use it...

Yes, but its a down level version. I believe its OpenSSL 0.9.8, but I could be wrong. You should try to avoid it if possible. For example, you don't get a library capable of TLS 1.2 because that was introduced in OpenSSL 1.0.1.

OpenSSL is loaded into every Android process. Its a byproduct of the fork from Zygote. So you always have the down level version of OpenSSL whether you want it or not.

You access OpenSSL via JNI. There's lots of Stack Overflow questions and answers covering it.

To use a newer OpenSSL, you have to write a wrapper shared object and link to the static library version of OpenSSL. You then reach the newer version of OpenSSL through JNI via your wrapper.

What I want to do is:

  • Create the keypair
  • Get private key
  • Get public key
  • Encrypt a text
  • Decrypt the text

When you are ready, you should probably ask separate questions if you encounter trouble.


For cross-compiling instructions, see Android on the OpenSSL wiki.


Need Your Help

Efficiently count the number of occurrences of unique subarrays in NumPy?

python arrays numpy counting

I have an array of shape (128, 36, 8) and I'd like to find the number of occurrences of the unique subarrays of length 8 in the last dimension.