-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to define a callback for FIPS test failures instead of ab…
…orting the process (#2162) ### Description of changes: This change adds a new build option `AWSLC_FIPS_FAILURE_CALLBACK` that then requires applications that links with AWS-LC to define the `AWS_LC_fips_failure_callback(const char* message)` function. If that function is not defined AWS-LC fails to load. When the callback is defined and a FIPS failure (CAST or PWCT) happens AWS-LC calls that function instead. It is up to the calling application to ensure no further cryptographic operations occur. This is not an approved way to use AWS-LC in FIPS mode, for the approved way to build and use AWS-LC see the latest FIPS security policy. ### Testing This change adds a new gtest that checks the callback function is called with the expected message and is used with break-kat.go and the runtime PCT environment variables to ensure the callback is passed the expected message. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
- Loading branch information
Showing
9 changed files
with
259 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR ISC | ||
source tests/ci/common_posix_setup.sh | ||
|
||
original_test="${BUILD_ROOT}/crypto/crypto_test" | ||
broken_test="${BUILD_ROOT}/crypto/crypto_test_broken" | ||
|
||
# By default the test should pass | ||
$original_test --gtest_filter=FIPSCallback.PowerOnSelfTests | ||
$original_test --gtest_filter=FIPSCallback.PWCT | ||
|
||
# Break the tests | ||
KATS=$(go run "${SRC_ROOT}/util/fipstools/break-kat.go" --list-tests) | ||
for kat in $KATS; do | ||
go run "${SRC_ROOT}/util/fipstools/break-kat.go" "$original_test" "$kat" > "$broken_test" | ||
chmod +x "$broken_test" | ||
export FIPS_CALLBACK_TEST_EXPECTED_FAILURE="$kat" | ||
# When a callback is defined AWS-LC will not abort and the test should exit successfully | ||
$broken_test --gtest_filter=FIPSCallback.PowerOnSelfTests | ||
unset FIPS_CALLBACK_TEST_EXPECTED_FAILURE | ||
done | ||
|
||
for TEST in RSA_PWCT ECDSA_PWCT EDDSA_PWCT MLKEM_PWCT MLDSA_PWCT; do | ||
export FIPS_CALLBACK_TEST_EXPECTED_FAILURE="${TEST}" | ||
export BORINGSSL_FIPS_BREAK_TEST="${TEST}" | ||
$original_test --gtest_filter=FIPSCallback.PWCT | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters