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

Android FIPS compatibility? #192

Closed
tomleavy opened this issue Jul 14, 2021 · 2 comments · Fixed by #299
Closed

Android FIPS compatibility? #192

tomleavy opened this issue Jul 14, 2021 · 2 comments · Fixed by #299
Labels

Comments

@tomleavy
Copy link

tomleavy commented Jul 14, 2021

Problem:

When -FIPS=ON is set for Android it results in a build failure

Relevant details

AWS-LC commit: 7ada846

Host Platform:

  • Arch: x86_64
  • OS: Ubuntu 18.04 (docker)

Target Platform:

  • Arch: x86_64 + armv8a
  • OS: Android NDK 20

Build log:

-- Check for working C compiler: /usr/opt/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /usr/opt/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/opt/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /usr/opt/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Test stdalign_check.c passed, enabling AWS_LC_STDALIGN_AVAILABLE
-- Test builtin_swap_check.c passed, enabling AWS_LC_BUILTIN_SWAP_SUPPORTED
-- The ASM compiler identification is Clang
-- Found assembler: /usr/opt/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/share/build/build_android/build_android_armeabi-v7a/third-party/openssl/aws-lc/openssl-prefix/src/openssl-build
[ 29%] Performing build step for 'openssl'
[  1%] Generating crypto_test_data.cc
Scanning dependencies of target crypto_test_data
[  1%] Building CXX object CMakeFiles/crypto_test_data.dir/crypto_test_data.cc.o
[  1%] Built target crypto_test_data
Scanning dependencies of target boringssl_gtest
[  1%] Building CXX object CMakeFiles/boringssl_gtest.dir/third_party/googletest/src/gtest-all.cc.o
[  2%] Linking CXX static library libboringssl_gtest.a
[  2%] Built target boringssl_gtest
Scanning dependencies of target global_target
[  2%] Built target global_target
Scanning dependencies of target test_support_lib
[  2%] Building CXX object crypto/test/CMakeFiles/test_support_lib.dir/abi_test.cc.o
[  2%] Building CXX object crypto/test/CMakeFiles/test_support_lib.dir/file_test.cc.o
[  2%] Building CXX object crypto/test/CMakeFiles/test_support_lib.dir/malloc.cc.o
[  3%] Building CXX object crypto/test/CMakeFiles/test_support_lib.dir/test_util.cc.o
[  3%] Building CXX object crypto/test/CMakeFiles/test_support_lib.dir/wycheproof_util.cc.o
[  3%] Linking CXX static library libtest_support_lib.a
[  3%] Built target test_support_lib
Scanning dependencies of target fipsmodule
[  3%] Building C object crypto/fipsmodule/CMakeFiles/fipsmodule.dir/fips_shared_support.c.o
[  3%] Built target fipsmodule
Scanning dependencies of target bcm_c_generated_asm
[  3%] Building C object crypto/fipsmodule/CMakeFiles/bcm_c_generated_asm.dir/bcm.c.o
clang: error: argument unused during compilation: '-Wa,--noexecstack' [-Werror,-Wunused-command-line-argument]
crypto/fipsmodule/CMakeFiles/bcm_c_generated_asm.dir/build.make:62: recipe for target 'crypto/fipsmodule/CMakeFiles/bcm_c_generated_asm.dir/bcm.c.o' failed
@bryce-shang
Copy link
Contributor

bryce-shang commented Jul 14, 2021

clang: error: argument unused during compilation: '-Wa,--noexecstack' [-Werror,-Wunused-command-line-argument]

Thank you for reporting this issue.

Currently, awslc FIPS build is just POC(Proof of concept) and only tested with clang-7 on Ubuntu 20.04(x86 and aarch) and AL2(x86 and aarch). awslc FIPS validation is in progress and does not plan to cover Android.

But we do expect awslc FIPS with clang-7 is buildable on the Android. Would you share the docker image (for reproduce)?

@tomleavy
Copy link
Author

You can take a look at my repo here: https://github.com/WickrInc/wickr-crypto-c

There is a branch for AWS-LC support and there is a script in the root directory that builds a docker image for the build and then executes it.

Thanks!

samuel40791765 added a commit that referenced this issue Nov 11, 2021
### Issues:
Resolves #192

### Description of changes: 
* Clang with the Android NDK doesn't compile with `-Werror` on clang due to implicit addition of `-Wa,noexecstack`. Since `--Wa,--noexecstack` is not used during the preprocessor step (because assembler is not invoked), Clang reports that argument as unused. Added a removal the flag during FIPS builds for Android. 
Context: android/ndk#171

* CMAKE inserts a `\` before whitespaces in arguments, which Android line does not recognize when using
  `add_custom_command`. This caused `${CMAKE_ASM_COMPILER}` to fail during the preprocessing step. Replacing whitespaces with `;` fixes this. 
  Context: https://stackoverflow.com/questions/8925396/why-does-cmake-prefixes-spaces-with-backslashes-when-executing-a-command

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
DominicDams pushed a commit to DominicDams/aws-lc that referenced this issue Nov 30, 2021
### Issues:
Resolves aws#192

### Description of changes: 
* Clang with the Android NDK doesn't compile with `-Werror` on clang due to implicit addition of `-Wa,noexecstack`. Since `--Wa,--noexecstack` is not used during the preprocessor step (because assembler is not invoked), Clang reports that argument as unused. Added a removal the flag during FIPS builds for Android. 
Context: android/ndk#171

* CMAKE inserts a `\` before whitespaces in arguments, which Android line does not recognize when using
  `add_custom_command`. This caused `${CMAKE_ASM_COMPILER}` to fail during the preprocessing step. Replacing whitespaces with `;` fixes this. 
  Context: https://stackoverflow.com/questions/8925396/why-does-cmake-prefixes-spaces-with-backslashes-when-executing-a-command

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
samuel40791765 added a commit that referenced this issue Mar 29, 2022
* AWS-LC wants to ensure that our tests and build work correctly 
on Android. Insipred from the CRT Team's 
`AWSCRTAndroidTestRunner`, this mini Android test harness is
 intended to be used within our Android CI with AWS Device Farm.
 The tests will include crypto_test, urandom_test, decrepit_test
and ssl_test, referenced from regular test dimensions. 
Using this test harness with AWS-LC will also help ensure that 
builds cross compiles successfully with the Android toolchains,
mitigating past issues like this: 
#192.

* ANDROIDTESTRUNNER is a new flag that I plan to add in AWS-LC 
that compiles our test executables from regular executables to 
so executables when ANDROIDTESTRUNNER is on. Only Shared 
Object files can be automatically packaged into an Android app 
with the right execution permissions, so test executable outputs 
need to be outputted as an so for AWSLCAndroidTestRunner to be
 able to execute the tests within the app dimension.
The actual ANDROIDTESTRUNNER change in AWS-LC is not in this 
PR, and this is just an early call out to the change I intend to make.
Taffer pushed a commit to Taffer/aws-lc that referenced this issue Aug 19, 2022
* AWS-LC wants to ensure that our tests and build work correctly 
on Android. Insipred from the CRT Team's 
`AWSCRTAndroidTestRunner`, this mini Android test harness is
 intended to be used within our Android CI with AWS Device Farm.
 The tests will include crypto_test, urandom_test, decrepit_test
and ssl_test, referenced from regular test dimensions. 
Using this test harness with AWS-LC will also help ensure that 
builds cross compiles successfully with the Android toolchains,
mitigating past issues like this: 
aws#192.

* ANDROIDTESTRUNNER is a new flag that I plan to add in AWS-LC 
that compiles our test executables from regular executables to 
so executables when ANDROIDTESTRUNNER is on. Only Shared 
Object files can be automatically packaged into an Android app 
with the right execution permissions, so test executable outputs 
need to be outputted as an so for AWSLCAndroidTestRunner to be
 able to execute the tests within the app dimension.
The actual ANDROIDTESTRUNNER change in AWS-LC is not in this 
PR, and this is just an early call out to the change I intend to make.
Taffer pushed a commit to Taffer/aws-lc that referenced this issue Sep 7, 2022
* AWS-LC wants to ensure that our tests and build work correctly 
on Android. Insipred from the CRT Team's 
`AWSCRTAndroidTestRunner`, this mini Android test harness is
 intended to be used within our Android CI with AWS Device Farm.
 The tests will include crypto_test, urandom_test, decrepit_test
and ssl_test, referenced from regular test dimensions. 
Using this test harness with AWS-LC will also help ensure that 
builds cross compiles successfully with the Android toolchains,
mitigating past issues like this: 
aws#192.

* ANDROIDTESTRUNNER is a new flag that I plan to add in AWS-LC 
that compiles our test executables from regular executables to 
so executables when ANDROIDTESTRUNNER is on. Only Shared 
Object files can be automatically packaged into an Android app 
with the right execution permissions, so test executable outputs 
need to be outputted as an so for AWSLCAndroidTestRunner to be
 able to execute the tests within the app dimension.
The actual ANDROIDTESTRUNNER change in AWS-LC is not in this 
PR, and this is just an early call out to the change I intend to make.
Taffer pushed a commit to Taffer/aws-lc that referenced this issue Sep 9, 2022
* AWS-LC wants to ensure that our tests and build work correctly 
on Android. Insipred from the CRT Team's 
`AWSCRTAndroidTestRunner`, this mini Android test harness is
 intended to be used within our Android CI with AWS Device Farm.
 The tests will include crypto_test, urandom_test, decrepit_test
and ssl_test, referenced from regular test dimensions. 
Using this test harness with AWS-LC will also help ensure that 
builds cross compiles successfully with the Android toolchains,
mitigating past issues like this: 
aws#192.

* ANDROIDTESTRUNNER is a new flag that I plan to add in AWS-LC 
that compiles our test executables from regular executables to 
so executables when ANDROIDTESTRUNNER is on. Only Shared 
Object files can be automatically packaged into an Android app 
with the right execution permissions, so test executable outputs 
need to be outputted as an so for AWSLCAndroidTestRunner to be
 able to execute the tests within the app dimension.
The actual ANDROIDTESTRUNNER change in AWS-LC is not in this 
PR, and this is just an early call out to the change I intend to make.
Taffer pushed a commit to Taffer/aws-lc that referenced this issue Sep 27, 2022
* AWS-LC wants to ensure that our tests and build work correctly 
on Android. Insipred from the CRT Team's 
`AWSCRTAndroidTestRunner`, this mini Android test harness is
 intended to be used within our Android CI with AWS Device Farm.
 The tests will include crypto_test, urandom_test, decrepit_test
and ssl_test, referenced from regular test dimensions. 
Using this test harness with AWS-LC will also help ensure that 
builds cross compiles successfully with the Android toolchains,
mitigating past issues like this: 
aws#192.

* ANDROIDTESTRUNNER is a new flag that I plan to add in AWS-LC 
that compiles our test executables from regular executables to 
so executables when ANDROIDTESTRUNNER is on. Only Shared 
Object files can be automatically packaged into an Android app 
with the right execution permissions, so test executable outputs 
need to be outputted as an so for AWSLCAndroidTestRunner to be
 able to execute the tests within the app dimension.
The actual ANDROIDTESTRUNNER change in AWS-LC is not in this 
PR, and this is just an early call out to the change I intend to make.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants