Skip to content

Commit 4863cb4

Browse files
committed
Android: add example of setting per-architecture verifyCore[] hash in CMakeLists.txt with WOLFCRYPT_FIPS_CORE_HASH_VALUE
1 parent 29bfb45 commit 4863cb4

1 file changed

Lines changed: 39 additions & 6 deletions

File tree

android/wolfssljni-ndk-gradle/app/CMakeLists.txt

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,45 @@ if ("${WOLFSSL_PKG_TYPE}" MATCHES "normal")
7474
)
7575

7676
elseif("${WOLFSSL_PKG_TYPE}" MATCHES "fipsready")
77+
# The wolfCrypt FIPS In Core Integrity checksum will vary with compiler
78+
# versions, runtime library versions, target hardware, and build type.
79+
# Anytime the module is shifted up or down in memory or loaded from a new
80+
# memory location the hash will change. This is expected during normal
81+
# development cycles but should be stable in a production deployment.
82+
# The verifyCore[] hash can be manually updated in
83+
# 'wolfcrypt/src/fips_test.c' and the app recompiled. Or, the define
84+
# WOLFCRYPT_FIPS_CORE_HASH_VALUE can be set below, which is helpful
85+
# for Android Studio, which builds for all these architectures in the same
86+
# build.
87+
#
88+
# The hash values below are only for reference and will need to
89+
# be updated to match your build. To update this value:
90+
#
91+
# 1. Build and install your app which contains wolfCrypt FIPS
92+
# 2. Run your app on each architecture, looking at the logcat output
93+
# to see the expected verifyCore[] hash value.
94+
# 3. Copy the expected hash value from logcat to the proper architecture
95+
# section below.
96+
# 4. Re-build your application now that the expected hash value has
97+
# been set.
98+
# 5. Re-install and re-run your application on each architecture to
99+
# confirm the hash is stable and application runs as expected.
100+
#
101+
# NOTE: If using wolfSSL FIPS Ready or FIPS proper with this sample
102+
# application and run into the scenario where the verifyCore[] hash output
103+
# at runtime is empty, consider checking/increasing the size of the
104+
# MAX_FIPS_DATA_SZ define in 'wolfcrypt/src/fips_test.c'.
105+
106+
if("${ANDROID_ABI}" MATCHES "arm64-v8a")
107+
add_definitions(-DWOLFCRYPT_FIPS_CORE_HASH_VALUE=6F0F3E0BDA9AF973D2B7243444DE8279DF9F98A533E60D1E076DE4B6B9416F11)
108+
elseif("${ANDROID_ABI}" MATCHES "armeabi-v7a")
109+
add_definitions(-DWOLFCRYPT_FIPS_CORE_HASH_VALUE=6F0F3E0BDA9AF973D2B7243444DE8279DF9F98A533E60D1E076DE4B6B9416F11)
110+
elseif("${ANDROID_ABI}" MATCHES "x86_64")
111+
add_definitions(-DWOLFCRYPT_FIPS_CORE_HASH_VALUE=6F0F3E0BDA9AF973D2B7243444DE8279DF9F98A533E60D1E076DE4B6B9416F11)
112+
elseif("${ANDROID_ABI}" MATCHES "x86")
113+
add_definitions(-DWOLFCRYPT_FIPS_CORE_HASH_VALUE=6F0F3E0BDA9AF973D2B7243444DE8279DF9F98A533E60D1E076DE4B6B9416F11)
114+
endif()
115+
77116
# Add preprocessor defines to CFLAGS, these match those placed into
78117
# wolfssl/options.h by configure if using: "./configure" on a Unix/Linux
79118
# platform. The options below have been chosen to match a FIPS Ready build,
@@ -82,12 +121,6 @@ elseif("${WOLFSSL_PKG_TYPE}" MATCHES "fipsready")
82121
# This list may be configurable depending on use case and desired
83122
# optimizations, being careful not to break FIPS compatibility if targeting
84123
# FIPS proper in the future.
85-
86-
# NOTE: If using wolfSSL FIPS Ready or FIPS proper with this sample
87-
# application and run into the scenario where the verifyCore[] hash output
88-
# at runtime is empty, consider checking/increasing the size of the
89-
# MAX_FIPS_DATA_SZ define in 'wolfcrypt/src/fips_test.c'.
90-
91124
add_definitions(-DHAVE_FIPS -DHAVE_FIPS_VERSION=5 -DHAVE_FIPS_VERSION_MINOR=3
92125
-DHAVE_HASHDRBG -DHAVE_THREAD_LS -DHAVE_REPRODUCIBLE_BUILD
93126
-DFP_MAX_BITS=16384 -DSP_INT_BITS=8192 -DWOLFSSL_PUBLIC_MP

0 commit comments

Comments
 (0)