-
Notifications
You must be signed in to change notification settings - Fork 174
[1] Refactor the swtpm_cert tests and fix some more issues in swtpm_cert #1123
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
Open
stefanberger
wants to merge
5
commits into
master
Choose a base branch
from
stefanberger/refactor_tests_and_fix_swtpm_cert
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+575
−1,012
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8c4b19b
build-sys: Require OpenSSL's libcrypto >= v3.5 for ML-KEM & ML-DSA su…
stefanberger c968042
CI: Require Ubuntu 26.04 with OpenSSL >= v3.5 for all test runners
stefanberger afd0437
swtpm_cert: Adjust error message for 'days' too far in future
stefanberger 41d6795
swtpm_cert: Fix the ASN.1 for IAK/IDevID SAN
stefanberger 2218e61
tests: Refactor certificate creation tests
stefanberger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,113 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # For the license, see the LICENSE file in the root directory. | ||
|
|
||
| ROOT=${abs_top_builddir:-$(dirname "$0")/..} | ||
| TESTDIR=${abs_top_testdir:=$(dirname "$0")} | ||
|
|
||
| source "${TESTDIR}/common" | ||
|
|
||
| trap "cleanup" SIGTERM EXIT | ||
|
|
||
| function cleanup() | ||
| { | ||
| rm -f "${cert}" "${pwdfile}" | ||
| } | ||
|
|
||
| cert="$(mktemp)" || exit 1 | ||
| pwdfile="$(mktemp)" || exit 1 | ||
|
|
||
| function check_cert_size() | ||
| { | ||
| local cert="$1" | ||
| local exp="$2" | ||
|
|
||
| local size | ||
|
|
||
| size=$(get_filesize "${cert}") | ||
| if [ "$size" -ne "$exp" ]; then | ||
| echo "Warning: Certificate file has unexpected size." | ||
| echo " Expected: $exp; found: $size" | ||
| fi | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| COMMON=( | ||
| --signkey "${PARAM_SIGNKEY_ENCRYPTED}" | ||
| --issuercert "${PARAM_ISSUERCERT}" | ||
| --out-cert "${cert}" | ||
| --days 3650 | ||
| --pem | ||
| --tpm-manufacturer IBM --tpm-model swtpm-libtpms --tpm-version 1.2 | ||
| --tpm-spec-family 1.2 --tpm-spec-revision 123 --tpm-spec-level 321 | ||
| ) | ||
|
|
||
| if ! VARNAME=${PARAM_PASSWORD} ${SWTPM_CERT} \ | ||
| "${COMMON[@]}" \ | ||
| --signkey-pwd env:VARNAME \ | ||
| --modulus 'b9dda830729de58f9f5bed2b3b9394ad4ec5afb9c390b89a3337250cbc575cfc8f31f7ffd3f05f4155076f7d1605381cd281b7f147b801154e4f89ee529fe36eae50f79561850e5b63037edaacbb390ea3fcd037e674fb179e3c5afe31214d78a756ca44cc6cf25421b51420ede548310c92b08a513ccc62fd0ef45dcf6546f6e865be6a661d045d1c47b60b428d11dc97cb9f35ee7c385bb20320934b015f8014e8fb19851c2af307e1e64648c142175e40b60615dc494fdb09ea5d5a6f3273b65a241e3cf30cc449b9fb3f900d1ed4be967b32b16f95a1d732dbfa143eaa1c2017556117f70faee5d77f836705d05405361ad5871a32161fa5a1234cfab497'; | ||
| then | ||
| echo "Error: ${SWTPM_CERT} returned error code." | ||
| exit 1 | ||
| fi | ||
|
|
||
| check_cert_size "${cert}" 1395 | ||
|
|
||
| # truncate result file | ||
| echo -n > "${cert}" | ||
| echo "Test 1: OK" | ||
|
|
||
| if ! ${SWTPM_CERT} \ | ||
| "${COMMON[@]}" \ | ||
| --signkey-pwd file:<(printf "%s" "${PARAM_PASSWORD}") \ | ||
| --modulus 'b9dda830729de58f9f5bed2b3b9394ad4ec5afb9c390b89a3337250cbc575cfc8f31f7ffd3f05f4155076f7d1605381cd281b7f147b801154e4f89ee529fe36eae50f79561850e5b63037edaacbb390ea3fcd037e674fb179e3c5afe31214d78a756ca44cc6cf25421b51420ede548310c92b08a513ccc62fd0ef45dcf6546f6e865be6a661d045d1c47b60b428d11dc97cb9f35ee7c385bb20320934b015f8014e8fb19851c2af307e1e64648c142175e40b60615dc494fdb09ea5d5a6f3273b65a241e3cf30cc449b9fb3f900d1ed4be967b32b16f95a1d732dbfa143eaa1c2017556117f70faee5d77f836705d05405361ad5871a32161fa5a1234cfab497'; | ||
| then | ||
| echo "Error: ${SWTPM_CERT} returned error code." | ||
| exit 1 | ||
| fi | ||
|
|
||
| #expecting size to be constant | ||
| check_cert_size "${cert}" 1395 | ||
|
|
||
| # truncate result file | ||
| echo -n > "${cert}" | ||
| echo "Test 2: OK" | ||
|
|
||
|
|
||
| if ! ${SWTPM_CERT} \ | ||
| "${COMMON[@]}" \ | ||
| --signkey-pwd "pass:${PARAM_PASSWORD}" \ | ||
| --pubkey "${PARAM_RSAPUBKEY}"; | ||
| then | ||
| echo "Error: ${SWTPM_CERT} returned error code." | ||
| exit 1 | ||
| fi | ||
|
|
||
| check_cert_size "${cert}" 1460 | ||
|
|
||
| # truncate result file | ||
| echo -n > "${cert}" | ||
| echo "Test 3: OK" | ||
|
|
||
|
|
||
| ###################### Platform Certificate ##################### | ||
|
|
||
| printf "%s" "${PARAM_PASSWORD}" > "${pwdfile}" | ||
| exec 100<"${pwdfile}" | ||
| if ! ${SWTPM_CERT} \ | ||
| --type platform \ | ||
| "${COMMON[@]}" \ | ||
| --signkey-pwd fd:100 \ | ||
| --pubkey "${PARAM_RSAPUBKEY}" \ | ||
| --platform-manufacturer Fedora \ | ||
| --platform-model QEMU \ | ||
| --platform-version 2.1; then | ||
| echo "Error: ${SWTPM_CERT} returned error code." | ||
| exit 1 | ||
| fi | ||
|
|
||
| #expecting size to be constant | ||
| check_cert_size "${cert}" 1489 | ||
|
|
||
| # truncate result file | ||
| echo -n > "${cert}" | ||
| echo "Test 4: OK" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.