Open-TEE / project

Overall project configuration and documentation
Apache License 2.0
80 stars 35 forks source link

Android build: tee_storage_api build error - Android M fixes required #10

Open lordqwerty opened 8 years ago

lordqwerty commented 8 years ago

Hello,

After doing a repo sync I now get the following error:

open-tee_error

$ make opentee-engine
....
....
....

opentee/emulator/internal_api/tee_storage_api.c: In function 'gen_des_key':
opentee/emulator/internal_api/tee_storage_api.c:151:2: warning: implicit declaration of function 'DES_random_key' [-Wimplicit-function-declaration]
  DES_random_key(&key1);
  ^
opentee/emulator/internal_api/tee_storage_api.c:152:2: error: incompatible type for argument 2 of 'memcpy'
  memcpy(object->attrs->content.ref.buffer, key1, sizeof(key1));
  ^
In file included from opentee/emulator/internal_api/tee_storage_api.c:26:0:
bionic/libc/include/string.h:191:7: note: expected 'const void * __restrict__' but argument is of type 'DES_cblock'
 void* memcpy(void* __restrict dest, const void* __restrict src, size_t copy_amount) {
       ^
opentee/emulator/internal_api/tee_storage_api.c:160:2: error: incompatible type for argument 2 of 'memcpy'
  memcpy((unsigned char *)object->attrs->content.ref.buffer + sizeof(key1), key2,
  ^
In file included from opentee/emulator/internal_api/tee_storage_api.c:26:0:
bionic/libc/include/string.h:191:7: note: expected 'const void * __restrict__' but argument is of type 'DES_cblock'
 void* memcpy(void* __restrict dest, const void* __restrict src, size_t copy_amount) {
       ^
opentee/emulator/internal_api/tee_storage_api.c:169:2: error: incompatible type for argument 2 of 'memcpy'
  memcpy((unsigned char *)object->attrs->content.ref.buffer + sizeof(key1) + sizeof(key2),
  ^
In file included from opentee/emulator/internal_api/tee_storage_api.c:26:0:
bionic/libc/include/string.h:191:7: note: expected 'const void * __restrict__' but argument is of type 'DES_cblock'
 void* memcpy(void* __restrict dest, const void* __restrict src, size_t copy_amount) {
       ^
ninja: build stopped: subcommand failed.
make: *** [ninja.intermediate] Error 1

Are you also getting this error?

Thanks for your time.

lordqwerty commented 8 years ago

Interestingly with the CyanogenMod 12.1 android source Open-TEE builds. To do this I run:

This builds successfully. But in the android source from Googles repo does not build with Open-TEE as shown in the above error. Again is this just me or is everyone getting this?

brianmcgillion commented 8 years ago

Hi Jorden,

Do you have Android M in your Google aosp repo? We have not yet run Open-TEE with M, so you should still run it under L. It appears that there are changes in boring SSL that we will have to address in Open-TEE to get it to run there.

Br, Brian

On Wed, Oct 7, 2015 at 5:06 PM, Jorden Whitefield notifications@github.com wrote:

Interestingly with the CyanogenMod 12.1 android source Open-TEE builds. To do this I run:

  • source ./build/envsetup.sh
  • breakfast
  • make clean && make opentee-engine

This builds successfully. But in the android source from Googles repo does not build with Open-TEE as shown in the above error. Again is this just me or is everyone getting this?

— Reply to this email directly or view it on GitHub https://github.com/Open-TEE/project/issues/10#issuecomment-146205235.

lordqwerty commented 8 years ago

Ah right ok. I'll continue to use CyanogenMod for now. Feel free to close the issue.

Thank you

brianmcgillion commented 8 years ago

Will leave it open, and have marked it to be done, when I have time to test with an M tree (soon, I hope :)

brianmcfadden commented 8 years ago

Not an issue with boringssl. openssl was removed from the Android 6.0.0 manifest repo. Try a 'git clone https://android.googlesource.com/platform/external/openssl' into the external directory and rebuild, maybe? You'd still need to comment out some boringssl modules to let the build behave correctly with openssl. No, it still has errors.

prebuilts/misc/linux-x86/ccache/ccache prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-g++ -nostdlib -Wl,-soname,libInternalApi.so -Wl,--gc-sections -Wl,-shared  -Lout/target/product/generic/obj/lib out/target/product/generic/obj/lib/crtbegin_so.o             out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/callbacks.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/openssl_1_0_2_beta_rsa_oaep.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/tee_bigint.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/tee_cancellation.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/tee_crypto_api.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/tee_internal_client_api.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/tee_memory.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/tee_panic.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/opentee_storage_common.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/opentee_internal_api.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/tee_storage_api.o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/tee_time_api.o          -Wl,--whole-archive   -Wl,--no-whole-archive   out/target/product/generic/obj/STATIC_LIBRARIES/libunwind_llvm_intermediates/libunwind_llvm.a out/target/product/generic/obj/STATIC_LIBRARIES/libcompiler_rt-extras_intermediates/libcompiler_rt-extras.a    prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x-google/../../../../arm-linux-androideabi/lib/armv7-a/libatomic.a prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x-google/armv7-a/libgcc.a -lssl -lcrypto -lc -lc++ -ldl -lc -lm  -o out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/LINKED/libInternalApi.so  -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--build-id=md5 -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--icf=safe -Wl,--hash-style=gnu -Wl,--fix-cortex-a8 -Wl,--hash-style=sysv   -Wl,--exclude-libs,libunwind_llvm.a -Wl,--no-undefined out/target/product/generic/obj/lib/crtend_so.o 
Open-TEE/emulator/internal_api/openssl_1_0_2_beta_rsa_oaep.c:121: error: undefined reference to 'OPENSSL_malloc'
Open-TEE/emulator/internal_api/openssl_1_0_2_beta_rsa_oaep.c:138: error: undefined reference to 'OPENSSL_free'
Open-TEE/emulator/internal_api/openssl_1_0_2_beta_rsa_oaep.c:181: error: undefined reference to 'OPENSSL_malloc'
Open-TEE/emulator/internal_api/openssl_1_0_2_beta_rsa_oaep.c:232: error: undefined reference to 'OPENSSL_free'
Open-TEE/emulator/internal_api/openssl_1_0_2_beta_rsa_oaep.c:239: error: undefined reference to 'OPENSSL_free'
Open-TEE/emulator/internal_api/tee_bigint.c:130: error: undefined reference to 'BN_num_bytes'
Open-TEE/emulator/internal_api/tee_bigint.c:141: error: undefined reference to 'BN_is_negative'
Open-TEE/emulator/internal_api/tee_bigint.c:282: error: undefined reference to 'BN_num_bytes'
Open-TEE/emulator/internal_api/tee_bigint.c:289: error: undefined reference to 'BN_num_bytes'
Open-TEE/emulator/internal_api/tee_bigint.c:352: error: undefined reference to 'BN_num_bytes'
Open-TEE/emulator/internal_api/tee_bigint.c:367: error: undefined reference to 'BN_is_negative'
Open-TEE/emulator/internal_api/tee_bigint.c:602: error: undefined reference to 'BN_is_negative'
Open-TEE/emulator/internal_api/tee_bigint.c:1076: error: undefined reference to 'BN_is_one'
Open-TEE/emulator/internal_api/tee_bigint.c:1134: error: undefined reference to 'BN_one'
Open-TEE/emulator/internal_api/tee_bigint.c:1135: error: undefined reference to 'BN_zero'
Open-TEE/emulator/internal_api/tee_bigint.c:1136: error: undefined reference to 'BN_zero'
Open-TEE/emulator/internal_api/tee_bigint.c:1137: error: undefined reference to 'BN_one'
Open-TEE/emulator/internal_api/tee_bigint.c:1139: error: undefined reference to 'BN_is_zero'
Open-TEE/emulator/internal_api/tee_crypto_api.c:92: error: undefined reference to 'OpenSSL_add_all_algorithms'
collect2: error: ld returned 1 exit status
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libInternalApi_intermediates/LINKED/libInternalApi.so] Error 1

There is some more work to do. Maybe it's time to migrate away from openssl.

brianmcfadden commented 8 years ago

It works on Android 6.0.0. I've got a manual process for build and install, but it wouldn't take alot of effort to make it a little more automated. It allows everything in Android to use boringssl and OpenTEE can use openssl.

10-17 20:30:03.493  1425  1425 E tee_manager: ../../OpenTEE/emulator/manager/ext_storage_stream_api_posix.c:storage_ext_init:100  storage path(/data/.TEE_secure_storage/)
10-17 20:30:03.500  1425  1425 E tee_manager: ../../OpenTEE/emulator/manager/mainloop.c:lib_main_loop:221  Entering the Manager mainloop
10-17 20:30:03.561  1426  1426 E tee_launcher: ../../OpenTEE/emulator/launcher/launcher_mainloop.c:lib_main_loop:151  Entering the launcher mainloop

conn_test_app can run to completion.

!!! SUCCESS !!!
Connection test app did not found any errors.
^^^ SUCCESS ^^^

Huzzah!

YangRongAtGit commented 8 years ago

Hello Brianmcfadden, I had the same build error about undefined reference to OpenSSL functions. Is it possible that you could describe how to build OpenSSL in ASOP in details?

I git clone the openssl into external/openssl

Based on the the openssl project https://github.com/eighthave/openssl-android I added different Android.mk files in the external/openssl, external/openssl/apps, external/openssl/crypto and external/openssl/ssl folder, added android-config.mk, and Application.mk to external/openssl folder. But when I run 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.

Shell I use boring instead openssl? Thanks