我建libcrypto.so.1.0.0與兼容的described here如何建立符合FIPS sqlcipher調用FIPS_mode_set(1)
FIPS我想包括libcrypto.so.1.0.0(通過創建符號鏈接在android libs文件夾中的文件libcrypto.so),並試圖調用FIPS_mode_set(1),我發現錯誤 - 作爲未定義的引用 - FIPS_mode_set(1)。
下面是其中詳細我按照這樣的步驟:
在類,net_sqlcipher_database_SQLiteDatabase.cpp(在JNI文件夾)在sqlcipher代碼,我包括以下標題文件:
#include <openssl/crypto.h> #include <openssl/fips.h> #include <openssl/ssl.h>
然後我在上述類
/*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 }
添加下述方法和我上面方法聲明下表中在SQLiteDatabase.java加入
//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}, };
然後(src文件夾中),我已經添加以下本機方法聲明:
//setting static public native void fips_set_mode(int i);
最後,我所謂上述方法在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); }
然後,我的確讓編譯sqlcipher代碼loadLibs方法。但我我收到以下錯誤
jni/net_sqlcipher_database_SQLiteDatabase.cpp:252: undefined reference to `FIPS_mode_set'.
請任何建議在這方面將不勝感激
您是否檢查包含路徑中是否有其他版本的OpenSSL?它可能使用第一個,如果這是系統自帶的那個,它可能會變老。 –
你能解決這個問題嗎?我在我的應用程序中看到相同的問題? – Karan
它確實存在,但我必須包含在mk文件的ldlib中 – user1699512