open-quantum-safe / oqs-provider

OpenSSL 3 provider containing post-quantum algorithms
https://openquantumsafe.org
MIT License
215 stars 87 forks source link

Issue with Loading oqsprovider.so on Android using OSSL_PROVIDER_load #539

Open moganty opened 1 week ago

moganty commented 1 week ago

Describe the bug

I have successfully built oqsprovider.so for the ARM64 architecture (Android) and its dependencies: libcrypto, libssl, and liboqs. However, during runtime, I encountered an issue where OSSL_PROVIDER_load fails to load oqsprovider.

To Reproduce Steps to reproduce the behaviour:

usecase is to create a PQC based X509 CSR on android device.

OSSL_LIB_CTX *libctx = initialize_openssl(confPath, "oqsprovider");

// Function to initialize OpenSSL and load necessary providers
OSSL_LIB_CTX *initialize_openssl(const char *config_path, const char *provider_name) {
   OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new();
   if (!libctx) {
      // fprintf(stderr, "Error creating OpenSSL library context\n");
       return NULL;
   }

   if (!OSSL_LIB_CTX_load_config(libctx, config_path)) {
      // fprintf(stderr, "Error loading OpenSSL configuration\n");
       OSSL_LIB_CTX_free(libctx);
       return NULL;
   }

   if (!OSSL_PROVIDER_load(libctx, provider_name)) {
       // fprintf(stderr, "Error loading provider: %s\n", provider_name);
      // Print detailed OpenSSL errors
       while ((err = ERR_get_error()) != 0) {
           char err_msg[256];
           ERR_error_string_n(err, err_msg, sizeof(err_msg));
           //printf("OpenSSL Error: %s\n", err_msg);
           __android_log_print(ANDROID_LOG_ERROR, LOG_TAG,"OpenSSL error:%s",err_msg);
       }
       OSSL_LIB_CTX_free(libctx);
       return NULL;
   }

   return libctx;
}

Expected behavior

oqsprovider should be loaded by the function OSSL_PROVIDER_load

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Errors:

Open SSL error: error:12800067:DSO support routines::could not load the shared library Open SSL error: error:12800067:DSO support routines::could not load the shared library Open SSL error: error:07880025:common libcrypto routines::reason(37) Error loading provider error: error:00000000:lib(0)::reason(0)

Additional context code works perfectly when ran for macOS.

baentsch commented 4 days ago

Thanks for the more detailed report @moganty . Unfortunately I do not have an environment available that would allow me to reproduce this problem. Further (accordingly), I do not consider Android a supported platform. Lastly, the problem can very well have to do with issues in openssl or liboqs on Android.