gpt4 book ai didi

java - 如何构建符合 fips 的 sqlcipher 来调用 FIPS_mode_set(1)

转载 作者:行者123 更新时间:2023-12-02 07:48:52 27 4
gpt4 key购买 nike

我使用符合 fips 的 libcrypto.so.1.0.0 构建了 described here

我尝试包含 libcrypto.so.1.0.0 (通过在 android libs 文件夹中为文件 libcrypto.so 创建符号链接(symbolic link))并尝试调用 FIPS_mode_set(1) ,其中我发现错误 - 作为 undefined reference - FIPS_mode_set(1 )。

以下是我详细遵循的步骤:

  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},
    };
  2. 然后在 SQLiteDatabase.java(在 src 文件夹中)中,我添加了以下 native 方法声明:

    //setting
    static public native void fips_set_mode(int i);
  3. 最后,我在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);

    }
  4. 然后我确实编译了 sqlcipher 代码..但我收到以下错误

    jni/net_sqlcipher_database_SQLiteDatabase.cpp:252: undefined reference to `FIPS_mode_set'.

请在这方面提出任何建议,我们将不胜感激

最佳答案

您是否已验证 fips.h 头文件存在? android-database-sqlcipher 项目的根 jni 文件夹中的 Android.mk 文件在构建期间包含 external/openssl/include 路径。

关于java - 如何构建符合 fips 的 sqlcipher 来调用 FIPS_mode_set(1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12596901/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com