diff options
author | Tim Rühsen <tim.ruehsen@gmx.de> | 2018-11-16 16:22:10 +0100 |
---|---|---|
committer | Tim Rühsen <tim.ruehsen@gmx.de> | 2018-12-18 11:26:57 +0100 |
commit | 8b6d0422fd7a4fbffcccfa56467208381928eb31 (patch) | |
tree | dc2a3e3ac5ae22932673c7a350be62b5db66a8e9 | |
parent | 9f564d2286a8a484c1b1f45fe4f6d988d6652878 (diff) | |
download | gnutls-8b6d0422fd7a4fbffcccfa56467208381928eb31.tar.gz |
tests/cert-tests/certtool-eddsa: Increase portability (fix for busybox)
Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
-rwxr-xr-x | tests/cert-tests/certtool-eddsa | 37 | ||||
-rw-r--r-- | 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 | |