【发布时间】:2012-09-26 07:44:52
【问题描述】:
我构建了 libcrypto.so.1.0.0 与 fips 兼容为 described here
我尝试包含 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'.
请在这方面提出任何建议
【问题讨论】:
-
您是否检查过您的包含路径中是否有其他版本的 OpenSSL?大概是用第一个吧,如果是系统自带的,那它可能比较老了。
-
你能解决这个问题吗?我在我的应用程序中看到了同样的问题?
-
它确实存在,但我必须包含在 mk 文件的 ldlibs 中
标签: java cryptography fips sqlcipher