我构建了符合 fips 的 libcrypto.so.1.0.0,如此处所述
我尝试包含 libcrypto.so.1.0.0(通过在 android libs 文件夹中为文件 libcrypto.so 创建符号链接)并尝试在我发现错误的地方调用 FIPS_mode_set(1) - 作为未定义的参考 - FIPS_mode_set(1)。
以下是我详细遵循的步骤:
在 sqlcipher 代码的类 net_sqlcipher_database_SQLiteDatabase.cpp (在 jni 文件夹中)中,我包含了以下头文件:
#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 }
我在下表中添加了上述方法声明
//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}, };
然后在 SQLiteDatabase.java (在 src 文件夹中),我添加了以下本地方法声明:
//setting static public native void fips_set_mode(int i);
最后,我在 SQLiteDatabase.java 的 loadLibs 方法中调用了上述方法
//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代码..但我收到了以下错误
jni/net_sqlcipher_database_SQLiteDatabase.cpp:252: undefined reference to `FIPS_mode_set'.
请在这方面的任何建议将不胜感激