Open-TEE/project

The library OpenSSL is unable to be built on Android 6.0.1

Opened this issue · 0 comments

Hello mighty Open-TEE coders,

I had some compile errors about undefined reference to OpenSSL functions.

Open-TEE/emulator/internal_api/openssl_1_0_2_beta_rsa_oaep.c:129: error: undefined reference to 'OPENSSL_malloc'
Open-TEE/emulator/internal_api/openssl_1_0_2_beta_rsa_oaep.c:189: error: undefined reference to 'OPENSSL_malloc'
Open-TEE/emulator/internal_api/tee_bigint.c:163: error: undefined reference to 'BN_swap'
Open-TEE/emulator/internal_api/tee_bigint.c:164: error: undefined reference to 'BN_swap'
Open-TEE/emulator/internal_api/tee_crypto_api.c:120: error: undefined reference to 'ENGINE_cleanup'
Open-TEE/emulator/internal_api/tee_crypto_api.c:121: error: undefined reference to 'CONF_modules_unload'
Open-TEE/emulator/internal_api/tee_crypto_api.c:2642: error: undefined reference to 'CMAC_CTX_cleanup'
Open-TEE/emulator/internal_api/tee_crypto_api.c:2935: error: undefined reference to 'CMAC_CTX_copy'
Open-TEE/emulator/internal_api/tee_crypto_api.c:1153: error: undefined reference to 'EVP_aes_128_xts'
Open-TEE/emulator/internal_api/tee_crypto_api.c:1174: error: undefined reference to 'EVP_des_ede_ecb'
Open-TEE/emulator/internal_api/tee_crypto_api.c:1158: error: undefined reference to 'EVP_aes_256_xts'
Open-TEE/emulator/internal_api/tee_crypto_api.c:1176: error: undefined reference to 'EVP_des_ede3_ecb'
Open-TEE/emulator/internal_api/tee_storage_api.c:158: error: undefined reference to 'DES_random_key'
Open-TEE/emulator/internal_api/tee_storage_api.c:166: error: undefined reference to 'DES_random_key'
Open-TEE/emulator/internal_api/tee_storage_api.c:175: error: undefined reference to 'DES_random_key'

[Attempt 0]
There was an issue about Open-TEE on Android M (opened issue 10)

Based on the solution mentioned by brianmcfadden, I git clone the openssl into AOSP sub-folder external/openssl. Added different Android.mk files in the external/openssl, external/openssl/apps, external/openssl/crypto, external/openssl/ssl folder along with android-config.mk, and Application.mk to external/openssl folder. The *.mk files are from https://github.com/eighthave/openssl-android

But when I run the command mm.

It had an error:

build/core/base_rules.mk:217: *** external/openssl/crypto: MODULE.TARGET.SHARED_LIBRARIES.libcrypto already defined by external/boringssl.
build/core/ninja.mk:155: recipe for target 'out/build-aosp_arm-mmm-external_openssl_Android.mk.ninja' failed
make: *** [out/build-aosp_arm-mmm-external_openssl_Android.mk.ninja] Error 1
make: Leaving directory '/home/rong/projects/Android/src'

I also tried to git clone the repository git clone https://github.com/eighthave/openssl-android .
directly, got the same error.

[Attempt 1]
Tried to port missing function from OpenSSL to Open-TEE, so Open-TEE is able to use BoringSSL on Android.

For most functions like OPENSSL_malloc or BN_swap, I could simply copy the implementation from OpenSSL. But functions EVP_* are special, like EVP_aes_128_xts or EVP_aes_256_xts, they are automatically generated in building process and I could not find the implementation online. So I believe this is a dead end.

[Attempt 2]
Tried to use prebuild OpenSSL library files. I copied library files libcrypto.so.1.0.0, libssl.so.1.0.0 and libc.so.1.0.0 from /lib/x86_64-linux-gnu/ into Open-TEE working repository along with OpenSSL headers from usr/include/opnessl. But the ninja builder does not like my configurations, so I have following build error:

Starting build with ninja
ninja: Entering directory `.'
ninja: error: 'out/target/product/generic/obj/SHARED_LIBRARIES/opnessl_libssl_intermediates/export_includes', needed by 'out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/import_includes', missing and no known rule to make it
build/core/ninja.mk:140: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1

#### make failed to build some targets (25 seconds) ####

I also asked about the build error here




All suggestions are welcome && Thanks in advance.