From: Alon Bar-Lev Date: Thu, 18 Jun 2015 06:41:53 +0000 (+0300) Subject: tests: key-tests: cleanup shell usage X-Git-Tag: gnutls_3_4_3~74 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c198ee2fd5bf9bb4debf8a56b5156a3c751a526e;p=thirdparty%2Fgnutls.git tests: key-tests: cleanup shell usage Add quotes for most usages of variables. Added ${} for variables. Signed-off-by: Alon Bar-Lev --- diff --git a/tests/key-tests/key-id b/tests/key-tests/key-id index 9bad211b26..7e09617b2a 100755 --- a/tests/key-tests/key-id +++ b/tests/key-tests/key-id @@ -22,23 +22,23 @@ set -e -srcdir=${srcdir:-.} -CERTTOOL=${CERTTOOL:-../../src/certtool$EXEEXT} +srcdir="${srcdir:-.}" +CERTTOOL="${CERTTOOL:-../../src/certtool$EXEEXT}" -PARAMS="--generate-certificate --load-privkey $srcdir/key-user.pem --load-ca-privkey $srcdir/key-ca.pem --template tmpl" +PARAMS="--generate-certificate --load-privkey '${srcdir}/key-user.pem' --load-ca-privkey '${srcdir}/key-ca.pem' --template tmpl" echo "serial = 0" > tmpl -#$CERTTOOL $PARAMS --load-ca-certificate $srcdir/ca-gnutls-keyid.pem \ +#eval "${CERTTOOL}" ${PARAMS} --load-ca-certificate $srcdir/ca-gnutls-keyid.pem \ # --outfile user-gnutls-keyid.pem 2> /dev/null -#$CERTTOOL $PARAMS --load-ca-certificate $srcdir/ca-no-keyid.pem \ +#eval "${CERTTOOL}" ${PARAMS} --load-ca-certificate $srcdir/ca-no-keyid.pem \ # --outfile user-no-keyid.pem 2> /dev/null -$CERTTOOL $PARAMS --load-ca-certificate $srcdir/ca-weird-keyid.pem \ +eval "${CERTTOOL}" ${PARAMS} --load-ca-certificate "${srcdir}/ca-weird-keyid.pem" \ --outfile user-weird-keyid.pem 2> /dev/null -if $CERTTOOL -i < user-weird-keyid.pem \ +if "${CERTTOOL}" -i < user-weird-keyid.pem \ | grep '7a2c7a6097460603cbfb28e8e219df18deeb4e0d' > /dev/null; then : else diff --git a/tests/key-tests/pkcs8 b/tests/key-tests/pkcs8 index 746bd98157..8ea8dc97eb 100755 --- a/tests/key-tests/pkcs8 +++ b/tests/key-tests/pkcs8 @@ -18,118 +18,118 @@ # along with GnuTLS; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -srcdir=${srcdir:-.} -CERTTOOL=${CERTTOOL:-../../src/certtool$EXEEXT} -GREP=${GREP:-grep} +srcdir="${srcdir:-.}" +CERTTOOL="${CERTTOOL:-../../src/certtool$EXEEXT}" +GREP="${GREP:-grep}" # check keys with password -$CERTTOOL --to-p8 --load-privkey $srcdir/key-ca.pem --password "1234" \ +"${CERTTOOL}" --to-p8 --load-privkey "${srcdir}/key-ca.pem" --password "1234" \ --outfile tmp-key-ca.p8 2>/dev/null -$GREP "BEGIN ENCRYPTED PRIVATE KEY" tmp-key-ca.p8 >/dev/null 2>&1 +${GREP} "BEGIN ENCRYPTED PRIVATE KEY" tmp-key-ca.p8 >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in converting key to PKCS #8 with password" - exit $rc + exit ${rc} fi -$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca.pem --password "1234" >/dev/null 2>&1 +"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca.pem" --password "1234" >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in reading PKCS #8 key with password" - exit $rc + exit ${rc} fi -$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca-1234.p8 --password "1234" >/dev/null 2>&1 +"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca-1234.p8" --password "1234" >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in reading saved PKCS #8 key with password" - exit $rc + exit ${rc} fi #keys encrypted with empty password -$CERTTOOL --to-p8 --load-privkey $srcdir/key-ca.pem --password "" \ +"${CERTTOOL}" --to-p8 --load-privkey "${srcdir}/key-ca.pem" --password "" \ --outfile tmp-key-ca.p8 2>/dev/null -$GREP "BEGIN PRIVATE KEY" tmp-key-ca.p8 >/dev/null 2>&1 +${GREP} "BEGIN PRIVATE KEY" tmp-key-ca.p8 >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in converting key to PKCS #8 with empty password" - exit $rc + exit ${rc} fi -$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca.pem --password "" >/dev/null 2>&1 +"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca.pem" --password "" >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in reading PKCS #8 key with empty password" - exit $rc + exit ${rc} fi -$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca-empty.p8 --password "" >/dev/null 2>&1 +"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca-empty.p8" --password "" >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in reading saved PKCS #8 key with empty password" - exit $rc + exit ${rc} fi #keys encrypted with null password -$CERTTOOL --to-p8 --load-privkey $srcdir/key-ca.pem --null-password \ +"${CERTTOOL}" --to-p8 --load-privkey "${srcdir}/key-ca.pem" --null-password \ --outfile tmp-key-ca.p8 2>/dev/null -$GREP "BEGIN ENCRYPTED PRIVATE KEY" tmp-key-ca.p8 >/dev/null 2>&1 +${GREP} "BEGIN ENCRYPTED PRIVATE KEY" tmp-key-ca.p8 >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in converting key to PKCS #8 with null password" - exit $rc + exit ${rc} fi -$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca.pem --null-password >/dev/null 2>&1 +"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca.pem" --null-password >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in reading PKCS #8 key with null password" - exit $rc + exit ${rc} fi -$CERTTOOL -k --pkcs8 --infile $srcdir/key-ca-null.p8 --null-password >/dev/null 2>&1 +"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ca-null.p8" --null-password >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in reading saved PKCS #8 key with null password" - exit $rc + exit ${rc} fi # Tests for PKCS #8 ECC keys -$CERTTOOL -k --infile $srcdir/key-ecc.pem >/dev/null 2>&1 +"${CERTTOOL}" -k --infile "${srcdir}/key-ecc.pem" >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in reading saved ECC key" - exit $rc + exit ${rc} fi -$CERTTOOL -k --pkcs8 --infile $srcdir/key-ecc.p8 >/dev/null 2>&1 +"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/key-ecc.p8" >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in reading saved PKCS #8 ECC key" - exit $rc + exit ${rc} fi -$CERTTOOL -k --pkcs8 --infile $srcdir/openssl-key-ecc.p8 >/dev/null 2>&1 +"${CERTTOOL}" -k --pkcs8 --infile "${srcdir}/openssl-key-ecc.p8" >/dev/null 2>&1 rc=$? # We're done. -if test "$rc" != "0"; then +if test "${rc}" != "0"; then echo "Error in reading saved openssl PKCS #8 ECC key" - exit $rc + exit ${rc} fi rm -f tmp-key-ca.p8