From 5ea4a0e34242835de2f5100d07c536e2cce5c9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Fri, 16 Nov 2018 16:22:10 +0100 Subject: tests/cert-tests/certtool-eddsa: Increase portability (fix for busybox) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tim Rühsen --- tests/cert-tests/certtool-eddsa | 37 ++++++++++++++----------------------- tests/scripts/common.sh | 1 + 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/tests/cert-tests/certtool-eddsa b/tests/cert-tests/certtool-eddsa index 8b2714dcde..c097fbf6c6 100755 --- a/tests/cert-tests/certtool-eddsa +++ b/tests/cert-tests/certtool-eddsa @@ -22,9 +22,9 @@ srcdir="${srcdir:-.}" CERTTOOL="${CERTTOOL:-../../src/certtool${EXEEXT}}" -DIFF="${DIFF:-diff -b -B}" KEYFILE=eddsa-privkey.$$.tmp TMPFILE=eddsa.$$.tmp +TMPFILE2=eddsa2.$$.tmp if ! test -x "${CERTTOOL}"; then exit 77 @@ -38,17 +38,17 @@ if test "${GNUTLS_FORCE_FIPS_MODE}" = 1;then exit 77 fi +. "${srcdir}/../scripts/common.sh" # Test certificate in draft-ietf-curdle-pkix-04 ${VALGRIND} "${CERTTOOL}" -i --infile "${srcdir}/data/cert-eddsa.pem" --outfile "${TMPFILE}" -rc=$? -if test "${rc}" != "0"; then +if test $? != 0; then echo "There was an issue parsing the certificate" exit 1 fi -$DIFF -I 'Not After:' ${TMPFILE} "${srcdir}/data/cert-eddsa.pem" +check_if_equal ${TMPFILE} "${srcdir}/data/cert-eddsa.pem" "Not After:" if test $? != 0;then echo "Error in parsing EdDSA cert" exit 1 @@ -56,13 +56,12 @@ fi # Test public key in draft-ietf-curdle-pkix-04 ${VALGRIND} "${CERTTOOL}" --pubkey-info --infile "${srcdir}/data/pubkey-eddsa.pem" --outfile "${TMPFILE}" -rc=$? -if test "${rc}" != "0"; then +if test $? != 0; then echo "Could not read an EdDSA public key" exit 1 fi -$DIFF ${TMPFILE} "${srcdir}/data/pubkey-eddsa.pem" +check_if_equal ${TMPFILE} "${srcdir}/data/pubkey-eddsa.pem" if test $? != 0;then echo "Error in parsing EdDSA public key" exit 1 @@ -72,16 +71,14 @@ fi # Create an RSA-PSS private key, restricted to the use with RSA-PSS ${VALGRIND} "${CERTTOOL}" --generate-privkey --pkcs8 --password '' \ --key-type eddsa --outfile "$KEYFILE" -rc=$? -if test "${rc}" != "0"; then +if test $? != 0; then echo "Could not generate an EdDSA key" exit 1 fi ${VALGRIND} "${CERTTOOL}" -k --password '' --infile "$KEYFILE" -rc=$? -if test "${rc}" != "0"; then +if test $? != 0; then echo "Could not read generated an EdDSA key" exit 1 fi @@ -92,16 +89,14 @@ ${VALGRIND} "${CERTTOOL}" --generate-self-signed \ --pkcs8 --load-privkey "$KEYFILE" --password '' \ --template "${srcdir}/templates/template-test.tmpl" \ --outfile "${TMPFILE}" -rc=$? -if test "${rc}" != "0"; then +if test $? != 0; then echo "Could not generate an EdDSA certificate from an EdDSA key" exit 1 fi ${VALGRIND} "${CERTTOOL}" --verify --load-ca-certificate "${TMPFILE}" --infile "${TMPFILE}" -rc=$? -if test "${rc}" != "0"; then +if test $? != 0; then echo "There was an issue verifying the generated certificate (1)" exit 1 fi @@ -113,33 +108,29 @@ ${VALGRIND} "${CERTTOOL}" --generate-certificate --key-type eddsa \ --load-ca-certificate "${srcdir}/../../doc/credentials/x509/ca.pem" \ --template "${srcdir}/templates/template-test.tmpl" \ --outfile "${TMPFILE}" 2>/dev/null -rc=$? -if test "${rc}" != "0"; then +if test $? != 0; then echo "Could not generate an EdDSA certificate $i" exit 1 fi ${VALGRIND} "${CERTTOOL}" --verify --load-ca-certificate "${srcdir}/../../doc/credentials/x509/ca.pem" --infile "${TMPFILE}" -rc=$? -if test "${rc}" != "0"; then +if test $? != 0; then echo "There was an issue verifying the generated certificate (2)" exit 1 fi -rm -f "${TMPFILE}" +rm -f "${TMPFILE}" "${TMPFILE2}" rm -f "${KEYFILE}" -. ${srcdir}/../scripts/common.sh check_for_datefudge # Test certificate chain using Ed25519 datefudge "2017-7-6" \ ${VALGRIND} "${CERTTOOL}" --verify-chain --infile ${srcdir}/data/chain-eddsa.pem -rc=$? -if test "${rc}" != "0"; then +if test $? != 0; then echo "There was an issue verifying the Ed25519 chain" exit 1 fi diff --git a/tests/scripts/common.sh b/tests/scripts/common.sh index adc69b3062..1cce09d04e 100644 --- a/tests/scripts/common.sh +++ b/tests/scripts/common.sh @@ -262,6 +262,7 @@ terminate_proc() { done kill_quiet -9 $pid sleep 0.1 +} # $1, $2: the two files to check for equality # $3: Strings to be ignored, separated by | -- cgit v1.2.1