Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
moganty opened this issue Oct 8, 2024 · 7 comments
Closed
Labels
question No code change required

Comments

@moganty
Copy link

moganty commented Oct 8, 2024

I have successfully built oqsprovider.so for the ARM64 architecture, along with its dependencies: libcrypto, libssl, and liboqs. However, I am encountering an issue during runtime where OSSL_PROVIDER_load fails to load oqsprovider.

I am currently working on an Android build and would greatly appreciate any suggestions or guidance on how to resolve this issue.

Here are some specifics:

I have verified that all the required libraries are correctly built and present in the appropriate directories.
The native code is integrated with my Android application using the NDK.
If anyone has experience with using OQS Provider on Android or insights into the loading mechanism of shared libraries in this context, your input would be invaluable.

Thank you for your help!

@moganty moganty added the question No code change required label Oct 8, 2024
@ashman-p
Copy link
Contributor

ashman-p commented Oct 8, 2024

Hi @moganty, How are you attempting to load the provider? Command line or programmatically? Could post the command or a debug application loading it as well as the actual error you are seeing?

@moganty
Copy link
Author

moganty commented Oct 9, 2024

Hi @ashman-p , I am loading the provider programmatically in an Android application. I have created an NDK module where I added my code to load the provider.

Here is the code:

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;
}

error log:

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)

lib folder path in code:

src/main/jnilibs/arm64-v8a/oqsprovider.so

file command:

file oqsprovider.so

oqsprovider.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=9613443c56c7ae218391ad3415b898478dc517eb, with debug_info, not stripped

Openssl version: 3.3.2

Let me know if you need more info

Thanks

@ashman-p
Copy link
Contributor

ashman-p commented Oct 9, 2024

Hi @moganty, Thanks for providing the info. Lets see if more experienced android developers will chime in.
Its interesting though that your error log was not displayed.
"__android_log_print(ANDROID_LOG_ERROR, LOG_TAG,"OpenSSL error:%s",err_msg);"

@moganty
Copy link
Author

moganty commented Oct 9, 2024

Thank you, @ashman-p. The provider works perfectly on macOS, but the same code fails on Android. Do you think OpenSSL is failing to load the provider in the Android environment? Or would it be better to post this issue in the OpenSSL forum for further assistance?

@baentsch
Copy link
Member

baentsch commented Oct 9, 2024

Or would it be better to post this issue in the OpenSSL forum for further assistance?

Before you do that I strongly advise you fill in all information we are asking for in a bug report.

I know it is tedious, but a) creating this template was tedious for us too, b) has proven to unearth (and solve) many problems even before an issue is raised and c) would deliver information I'd ask for anyway (incl. in an OpenSSL forum). Thanks.

@moganty
Copy link
Author

moganty commented Oct 10, 2024

created a bug here. #539

@baentsch
Copy link
Member

Issue replaced by more detailed report in #539

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question No code change required
Projects
None yet
Development

No branches or pull requests

3 participants