0

I need to encrypt or decrypt a string using AES in C language(ndk), I saw lot of questions on how to compile openssl for android, I need to know when openssl is already available on android cant we use the same for encryption in C? If not, I need to compile whole openssl lib, is there any other lightweight lib which I can use for standard encryption in android using ndk?

Sandeep Manne
  • 6,030
  • 5
  • 39
  • 55

1 Answers1

2

Openssl for android is not part of the NDK, so you cannot use it immediately. However, Google provides a NDK compilable codebase for it as an external library (see https://github.com/android/platform_external_openssl). You'll need to compile it and then use it. If you do, take a look at Building Android openssl using NDK doesn't make arm4 assembly files properly.

As for lightweight libraries, you can find a list of AES implementations in C on the page http://en.wikipedia.org/wiki/AES_implementations#C.2FASM_library. However, most libraries will be feature rich, thus you'll have loads of code that you will not use. Instead, you may look at imbedding a reference AES implementation directly into your code and using that instead. One such implementation can be found at http://embeddedsw.net/Cipher_Reference_Home.html.

Community
  • 1
  • 1
Samveen
  • 3,482
  • 35
  • 52
  • But openssl is available in android os, cant we use that? – Sandeep Manne May 03 '12 at 10:09
  • NDK does not contain the headers or the libs for openssl. Google just provides the NDK compilable sources. So if you use the NDK to build your program, you'll have to build the openssl lib yourself. try "find $NDK_ROOT |grep -i ssl" – Samveen May 03 '12 at 10:14
  • Sandeep did u get any help on this ? Please share by answering this question. I am facing the same problem. Thanks a lot – png May 20 '12 at 06:33