I built libcrypto.so.1.0.0 with fips compliant as described here
I tried to include libcrypto.so.1.0.0 (by creating symbolic link for the file libcrypto.so in android libs folder) and tried to call FIPS_mode_set(1) where I find error - as undefined reference - FIPS_mode_set(1).
Here are steps where in detail I have followed so :
In class,net_sqlcipher_database_SQLiteDatabase.cpp (in jni folder) in the sqlcipher code, I included the following headers files :
#include <openssl/crypto.h>
#include <openssl/fips.h>
#include <openssl/ssl.h>
Then I added the following method in the above class
/*fips mode enable native native void fips_set_mode(int i) */
static void fips_set_mode(JNIEnv* env,jobject object,jint i){
FIPS_mode_set(1); // it should call FIPS_mode_set(1) from fips.c class
}
and I have added above method declaration in the following table
//methods
static JNINativeMethod sMethods[] =
{
/* name, signature, funcPtr */
{"dbopen", "(Ljava/lang/String;I)V", (void *)dbopen},
{"fips_set_mode","(I)V",(void *)fips_set_mode},
{"dbclose", "()V", (void *)dbclose},
{"enableSqlTracing", "(Ljava/lang/String;)V", (void *)enableSqlTracing},
{"enableSqlProfiling", "(Ljava/lang/String;)V", (void *)enableSqlProfiling},
{"native_execSQL", "(Ljava/lang/String;)V", (void *)native_execSQL},
{"lastInsertRow", "()J", (void *)lastInsertRow},
{"lastChangeCount", "()I", (void *)lastChangeCount},
{"native_setLocale", "(Ljava/lang/String;I)V", (void *)native_setLocale},
{"native_getDbLookaside", "()I", (void *)native_getDbLookaside},
{"releaseMemory", "()I", (void *)native_releaseMemory},
{"setICURoot", "(Ljava/lang/String;)V", (void *)setICURoot},
{"native_rawExecSQL", "(Ljava/lang/String;)V", (void *)native_rawExecSQL},
{"native_status", "(IZ)I", (void *)native_status},
};
Then in SQLiteDatabase.java (in the src folder), I have added following native method declaration :
//setting
static public native void fips_set_mode(int i);
Finally, I called above method in loadLibs method of SQLiteDatabase.java
//loadlibs
public static void loadLibs (Context context, File workingDir)
{
System.loadLibrary("stlport_shared");
System.loadLibrary("sqlcipher_android");
System.loadLibrary("database_sqlcipher");
fips_set_mode(1);
}
Then I did make to compile the sqlcipher code.. But I am getting following error
jni/net_sqlcipher_database_SQLiteDatabase.cpp:252: undefined reference to `FIPS_mode_set'.
Please any suggestion's in this regard would be appreciated
Have you verified that the fips.h
header file exists? The Android.mk
file within the root jni folder for android-database-sqlcipher project includes the external/openssl/include
path during the build.