-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some distributions (Fedora 41) are starting to block sha1 hashes. This prevents some test cases. The change is documented: https://fedoraproject.org/wiki/SHA1SignaturesGuidance. However, there is no API provided by openssl to detect if sha1 is supported or not. As a workaraound a scripts gets added which does that by singing and verifying some dummy data. Disabling sha1 by default was introduced to Fedora 41 by this commit: https://gitlab.com/redhat-crypto/fedora-crypto-policies/-/commit/035c735a8310af5e3999c327d96ad5e354837250 Removing the following 2 lines from /etc/crypto-policies/back-ends/opensslcnf.config [evp_properties] rh-allow-sha1-signatures = no allows to run the tests successfully also with sha1. The test log also shows that with sha1 supported the tests are executed and without sha1 support the tests are skipped for HASH=sha1. Signed-off-by: Adrian Freihofer <adrian.freihofer@gmail.com>
- Loading branch information
Showing
5 changed files
with
42 additions
and
3 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
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,32 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
# SHA-1 is considered as insecure by some Linux distributions. | ||
# So far there is no official API to detect SHA-1 support at run-time. | ||
# This script checks if a hash is supported for signing. | ||
# More details: https://fedoraproject.org/wiki/SHA1SignaturesGuidance | ||
|
||
set -e -o pipefail | ||
|
||
tmpdir=$(mktemp -d) | ||
cleanup() { | ||
rm -rf "$tmpdir" | ||
} | ||
trap cleanup EXIT | ||
|
||
if [ $# -eq 1 ]; then | ||
DGST_ALGO=$1 | ||
else | ||
echo "Please pass the algorithm. Example sha1" | ||
exit 1 | ||
fi | ||
|
||
# TPM2 must support it | ||
tpm2_getcap algorithms | grep -q "$DGST_ALGO" | ||
|
||
# openssl must support it | ||
openssl genpkey -algorithm RSA -out "$tmpdir/private_key.pem" -pkeyopt rsa_keygen_bits:2048 &>/dev/null | ||
openssl rsa -pubout -in "$tmpdir/private_key.pem" -out "$tmpdir/public_key.pem" &>/dev/null | ||
echo "Some data" > "$tmpdir/data.txt" | ||
openssl dgst "-$DGST_ALGO" -sign "$tmpdir/private_key.pem" -out "$tmpdir/signature" "$tmpdir/data.txt" &>/dev/null | ||
openssl dgst "-$DGST_ALGO" -verify "$tmpdir/public_key.pem" -signature "$tmpdir/signature" "$tmpdir/data.txt" &>/dev/null |
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