Skip to content

Commit

Permalink
Use the PKG_CONFIG_PATH variable in tests environment
Browse files Browse the repository at this point in the history
  • Loading branch information
olszomal committed Feb 3, 2023
1 parent 8384cd3 commit 1ce7539
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 10 deletions.
1 change: 1 addition & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ TESTS = $(dist_check_SCRIPTS)
TESTS_ENVIRONMENT = \
LC_ALL="C" \
EXEEXT=$(EXEEXT) \
PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" \
top_builddir="$(top_builddir)" \
srcdir="$(srcdir)"

Expand Down
11 changes: 11 additions & 0 deletions tests/ec-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
# along with GnuTLS; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

# OpenSSL settings
if test -n "${PKG_CONFIG_PATH}"
then
OPENSSL_PATH="${PKG_CONFIG_PATH}/../.."
OPENSSL="${OPENSSL_PATH}/bin/openssl"
export LD_LIBRARY_PATH="${OPENSSL_PATH}/lib:${OPENSSL_PATH}/lib64"
else
OPENSSL=openssl
fi
echo "Compiled with: `${OPENSSL} version`"

OPENSSL_VERSION=$(./openssl_version | cut -d ' ' -f 2)
case "${OPENSSL_VERSION}" in
0.*)
Expand Down
13 changes: 12 additions & 1 deletion tests/ec-no-cert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
# along with GnuTLS; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

# OpenSSL settings
if test -n "${PKG_CONFIG_PATH}"
then
OPENSSL_PATH="${PKG_CONFIG_PATH}/../.."
OPENSSL="${OPENSSL_PATH}/bin/openssl"
export LD_LIBRARY_PATH="${OPENSSL_PATH}/lib:${OPENSSL_PATH}/lib64"
else
OPENSSL=openssl
fi
echo "Compiled with: `${OPENSSL} version`"

OPENSSL_VERSION=$(./openssl_version | cut -d ' ' -f 2)
case "${OPENSSL_VERSION}" in
0.*)
Expand Down Expand Up @@ -115,7 +126,7 @@ if test $? != 0;then
exit 1;
fi

openssl x509 -in ${srcdir}/ec-cert.der -inform DER -out ${outdir}/ec-cert.pem -outform PEM
${OPENSSL} x509 -in ${srcdir}/ec-cert.der -inform DER -out ${outdir}/ec-cert.pem -outform PEM

echo "***************"
echo "Listing objects"
Expand Down
13 changes: 12 additions & 1 deletion tests/ec-no-pubkey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# OpenSSL settings
if test -n "${PKG_CONFIG_PATH}"
then
OPENSSL_PATH="${PKG_CONFIG_PATH}/../.."
OPENSSL="${OPENSSL_PATH}/bin/openssl"
export LD_LIBRARY_PATH="${OPENSSL_PATH}/lib:${OPENSSL_PATH}/lib64"
else
OPENSSL=openssl
fi
echo "Compiled with: `${OPENSSL} version`"

OPENSSL_VERSION=$(./openssl_version | cut -d ' ' -f 2)
case "${OPENSSL_VERSION}" in
0.*)
Expand Down Expand Up @@ -114,7 +125,7 @@ if test $? != 0;then
exit 1;
fi

openssl x509 -in ${srcdir}/ec-cert.der -inform DER -out ${outdir}/ec-cert.pem -outform PEM
${OPENSSL} x509 -in ${srcdir}/ec-cert.der -inform DER -out ${outdir}/ec-cert.pem -outform PEM

echo "***************"
echo "Listing objects"
Expand Down
4 changes: 2 additions & 2 deletions tests/pkcs11-uri-without-token.softhsm
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ PUBLIC_KEY="pkcs11:object=server-key;type=public;pin-value=1234"
echo "secret" >"${outdir}/in.txt"

# Generate signature without specifying the token in the PKCS#11 URI
openssl pkeyutl -engine pkcs11 -keyform engine -inkey "${PRIVATE_KEY}" \
${OPENSSL} pkeyutl -engine pkcs11 -keyform engine -inkey "${PRIVATE_KEY}" \
-sign -out "${outdir}/signature.bin" -in "${outdir}/in.txt"
if test $? != 0;then
echo "Failed to generate signature using PKCS#11 URI ${PRIVATE_KEY}"
exit 1;
fi

# Verify the signature without specifying the token in the PKCS#11 URI
openssl pkeyutl -engine pkcs11 -keyform engine -pubin -inkey "${PUBLIC_KEY}" \
${OPENSSL} pkeyutl -engine pkcs11 -keyform engine -pubin -inkey "${PUBLIC_KEY}" \
-verify -sigfile "${outdir}/signature.bin" -in "${outdir}/in.txt"
if test $? != 0;then
echo "Failed to verify signature using PKCS#11 URI ${PUBLIC_KEY}"
Expand Down
11 changes: 11 additions & 0 deletions tests/rsa-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
# along with GnuTLS; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

# OpenSSL settings
if test -n "${PKG_CONFIG_PATH}"
then
OPENSSL_PATH="${PKG_CONFIG_PATH}/../.."
OPENSSL="${OPENSSL_PATH}/bin/openssl"
export LD_LIBRARY_PATH="${OPENSSL_PATH}/lib:${OPENSSL_PATH}/lib64"
else
OPENSSL=openssl
fi
echo "Compiled with: `${OPENSSL} version`"

echo "Current directory: $(pwd)"
echo "Source directory: ${srcdir}"
echo "Output directory: ${outdir}"
Expand Down
13 changes: 12 additions & 1 deletion tests/rsa-no-pubkey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# OpenSSL settings
if test -n "${PKG_CONFIG_PATH}"
then
OPENSSL_PATH="${PKG_CONFIG_PATH}/../.."
OPENSSL="${OPENSSL_PATH}/bin/openssl"
export LD_LIBRARY_PATH="${OPENSSL_PATH}/lib:${OPENSSL_PATH}/lib64"
else
OPENSSL=openssl
fi
echo "Compiled with: `${OPENSSL} version`"

OPENSSL_VERSION=$(./openssl_version | cut -d ' ' -f 2)
case "${OPENSSL_VERSION}" in
0.*)
Expand Down Expand Up @@ -115,7 +126,7 @@ if test $? != 0;then
exit 1;
fi

openssl x509 -in ${srcdir}/rsa-cert.der -inform DER -out ${outdir}/rsa-cert.pem -outform PEM
${OPENSSL} x509 -in ${srcdir}/rsa-cert.der -inform DER -out ${outdir}/rsa-cert.pem -outform PEM

echo "***************"
echo "Listing objects"
Expand Down
10 changes: 5 additions & 5 deletions tests/search-all-matching-tokens.softhsm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ CERTIFICATE="pkcs11:object=label-3;type=cert;pin-value=1234"
echo "secret" > "${outdir}/in.txt"

# Verify that it doesn't try to login if more than one token matched the search
openssl pkeyutl -engine pkcs11 -keyform engine \
${OPENSSL} pkeyutl -engine pkcs11 -keyform engine \
-inkey "${PRIVATE_KEY_WITHOUT_TOKEN}" \
-sign -out "${outdir}/signature.bin" -in "${outdir}/in.txt"
if test $? = 0;then
Expand All @@ -80,7 +80,7 @@ if test $? = 0;then
fi

# Generate signature specifying the token in the PKCS#11 URI
openssl pkeyutl -engine pkcs11 -keyform engine -inkey "${PRIVATE_KEY}" \
${OPENSSL} pkeyutl -engine pkcs11 -keyform engine -inkey "${PRIVATE_KEY}" \
-sign -out "${outdir}/signature.bin" -in "${outdir}/in.txt"
if test $? != 0;then
echo "Failed to sign file using PKCS#11 URI ${PRIVATE_KEY}"
Expand All @@ -91,7 +91,7 @@ fi
i=0
while [ $i -le ${NUM_DEVICES} ]; do
pubkey="pkcs11:object=label-$i;type=public;pin-value=1234"
openssl pkeyutl -engine pkcs11 -keyform engine -pubin -inkey "${pubkey}" \
${OPENSSL} pkeyutl -engine pkcs11 -keyform engine -pubin -inkey "${pubkey}" \
-verify -sigfile "${outdir}/signature.bin" -in "${outdir}/in.txt"
if test $? != 0;then
echo "Failed to verify the signature using the PKCS#11 URI ${pubkey}"
Expand All @@ -101,15 +101,15 @@ while [ $i -le ${NUM_DEVICES} ]; do
done

# Verify the signature using a certificate without specifying the token
openssl pkeyutl -engine pkcs11 -keyform engine -pubin -inkey "${CERTIFICATE}" \
${OPENSSL} pkeyutl -engine pkcs11 -keyform engine -pubin -inkey "${CERTIFICATE}" \
-verify -sigfile "${outdir}/signature.bin" -in "${outdir}/in.txt"
if test $? != 0;then
echo "Failed to verify the signature using the PKCS#11 URI ${CERTIFICATE}"
exit 1;
fi

# Verify the signature using the first public key found
openssl pkeyutl -engine pkcs11 -keyform engine -pubin -inkey "${PUBLIC_KEY_ANY}" \
${OPENSSL} pkeyutl -engine pkcs11 -keyform engine -pubin -inkey "${PUBLIC_KEY_ANY}" \
-verify -sigfile "${outdir}/signature.bin" -in "${outdir}/in.txt"
if test $? != 0;then
echo "Failed to verify the signature using the PKCS#11 URI ${PUBLIC_KEY_ANY}."
Expand Down

0 comments on commit 1ce7539

Please sign in to comment.