You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add build option for exposing self-test failure messages (#433)
*Issue #, if available:* ACCP-129
_**THIS FEATURE IS NOT INTENDED FOR PRODUCTION AND IS THUS LEFT
UNDOCUMENTED IN OUR README**_
## Notes
This PR builds on prior work from @amirhosv on the
`fips-experimentation` branch to provide an alternative mode of handling
AWS-LC self test failures. We call this (non-default) mode
`FIPS_SELF_TEST_SKIP_ABORT`, and it is only usable when ACCP is built in
FIPS mode.
By default, AWS-LC will `abort()` on self-test failures. However, as of
AWS-LC v1.47, when built with the `AWSLC_FIPS_FAILURE_CALLBACK` build
flag AWS-LC will [call][1] a [weak symbol][2]
`AWS_LC_fips_failure_callback` function to handle self test failures
instead of aborting. When ACCP is built with
`-DFIPS_SELF_TEST_SKIP_ABORT`, ACCP defines
`AWS_LC_fips_failure_callback` such that it appends to a queue of error
strings in ACCP's native heap. To manage the accumulated error strings,
we add a native `std::vector` wrapper `ConcurrentStringVector` providing
a minimal, threadsafe API. Once the error queue is non-empty, all
subsequent `getInstance` calls on an algorithm provided by ACCP will
throw `FipsStatusException`.
We provide two functions for callers to query fips self test error state
on an `AmazonCorrettoCryptoProvider` instance:
- `public boolean isFipsStatusOk()`
- `public List<String> getFipsSelfTestFailures()`
We could get away with only the latter function, but we provide
`isFipsStatusOk()` to avoid performance costs of copying error strings
over the JNI.
[1]:
https://github.com/aws/aws-lc/blob/1d8b807ed1ae75c89beda6c73a4ae27c404fa46f/crypto/fipsmodule/bcm.c#L416
[2]:
https://github.com/aws/aws-lc/blob/1d8b807ed1ae75c89beda6c73a4ae27c404fa46f/crypto/internal.h#L1427-L1432
## Testing
To adequately test the new mode, we need to build AWS-LC with
`FIPS_BREAK_TEST=TESTS` to programmatically break AWS-LC's pairwise
consistency tests (PCTs). We test against each available PCT breakage
during key generation by setting the appropriate environment variable,
indicating which PCT to break. Unfortunately, Java doesn't appear to
have a standard utility for manipulating process environment variables
at runtime, so we create our own `TestUtil.setEnv` that calls POSIX
`setenv`/`unsetenv` over the JNI.
In addition to CI tests, I've also executed `run_accp_basic_tests.sh`
with the new `--fips-self-test-failure-no-abort` flag, which will
eventually be incorporated into our GitHub CI.
```
$ TEST_JAVA_HOME=/usr/lib/jvm/java-17-amazon-corretto.x86_64 ./tests/ci/run_accp_basic_tests.sh --fips-self-test-failure-no-abort
...
BUILD SUCCESSFUL in 40m 15s
18 actionable tasks: 13 executed, 5 up-to-date
```
---
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
---------
Co-authored-by: Amir Vakili <[email protected]>
Co-authored-by: Amir Vakili <[email protected]>
Co-authored-by: Gerardo Ravago 🇵🇭 <[email protected]>
set(ORIG_SRCROOT ${PROJECT_SOURCE_DIR}CACHESTRING"Path to root of original package")
43
43
set(PROVIDER_VERSION_STRING ""CACHESTRING"X.Y.Z formatted version of the provider")
44
44
set(EXPERIMENTAL_FIPS NOCACHEBOOL"Determines if this build is for FIPS mode with extra features from a non-FIPS branch of AWS-LC.")
45
+
set(FIPS_SELF_TEST_SKIP_ABORT NOCACHEBOOL"Determines whether ACCP throws exceptions on self-test failure, or AWS-LC aborts. If NO, AWS-LC aborts. If YES, ACCP will provide error messages.")
45
46
set(FIPS NOCACHEBOOL"Determine if this build is for FIPS mode")
46
47
set(ALWAYS_ALLOW_EXTERNAL_LIB NOCACHEBOOL"Always permit tests to load ACCP shared objects from the library path")
47
48
set(AWS_LC_VERSION_STRING ""CACHESTRING"Git version of AWS-LC used in this build")
0 commit comments