From 5cf4499261c9c6600ad27c90a9a9f241bed3461c Mon Sep 17 00:00:00 2001 From: dtucker Date: Mon, 24 May 2021 10:25:18 +0000 Subject: [PATCH] Find openssl binary via environment variable. This allows overriding if necessary (eg in -portable where we're testing against a specific version of OpenSSL). --- regress/usr.bin/ssh/agent-pkcs11.sh | 12 ++++++------ regress/usr.bin/ssh/percent.sh | 4 ++-- regress/usr.bin/ssh/ssh2putty.sh | 6 +++--- regress/usr.bin/ssh/test-exec.sh | 6 +++++- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/regress/usr.bin/ssh/agent-pkcs11.sh b/regress/usr.bin/ssh/agent-pkcs11.sh index 70b1f071480..7ade203a112 100644 --- a/regress/usr.bin/ssh/agent-pkcs11.sh +++ b/regress/usr.bin/ssh/agent-pkcs11.sh @@ -1,4 +1,4 @@ -# $OpenBSD: agent-pkcs11.sh,v 1.7 2019/11/26 23:43:10 djm Exp $ +# $OpenBSD: agent-pkcs11.sh,v 1.8 2021/05/24 10:25:18 dtucker Exp $ # Placed in the Public Domain. tid="pkcs11 agent test" @@ -46,16 +46,16 @@ notty() { trace "generating keys" RSA=${DIR}/RSA EC=${DIR}/EC -openssl genpkey -algorithm rsa > $RSA -openssl pkcs8 -nocrypt -in $RSA |\ +$OPENSSL genpkey -algorithm rsa > $RSA +$OPENSSL pkcs8 -nocrypt -in $RSA |\ softhsm2-util --slot "$slot" --label 01 --id 01 --pin "$TEST_SSH_PIN" --import /dev/stdin -openssl genpkey \ +$OPENSSL genpkey \ -genparam \ -algorithm ec \ -pkeyopt ec_paramgen_curve:prime256v1 |\ - openssl genpkey \ + $OPENSSL genpkey \ -paramfile /dev/stdin > $EC -openssl pkcs8 -nocrypt -in $EC |\ +$OPENSSL pkcs8 -nocrypt -in $EC |\ softhsm2-util --slot "$slot" --label 02 --id 02 --pin "$TEST_SSH_PIN" --import /dev/stdin trace "start agent" diff --git a/regress/usr.bin/ssh/percent.sh b/regress/usr.bin/ssh/percent.sh index f60916706c8..38e9b4d7730 100644 --- a/regress/usr.bin/ssh/percent.sh +++ b/regress/usr.bin/ssh/percent.sh @@ -1,4 +1,4 @@ -# $OpenBSD: percent.sh,v 1.11 2021/02/05 22:03:40 dtucker Exp $ +# $OpenBSD: percent.sh,v 1.12 2021/05/24 10:25:18 dtucker Exp $ # Placed in the Public Domain. tid="percent expansions" @@ -74,7 +74,7 @@ for i in matchexec localcommand remotecommand controlpath identityagent \ fi # Matches implementation in readconf.c:ssh_connection_hash() HASH=`printf "${HOSTNAME}127.0.0.1${PORT}$REMUSER" | - openssl sha1 | cut -f2 -d' '` + $OPENSSL sha1 | cut -f2 -d' '` trial $i '%%' '%' trial $i '%C' $HASH trial $i '%i' $USERID diff --git a/regress/usr.bin/ssh/ssh2putty.sh b/regress/usr.bin/ssh/ssh2putty.sh index 9f3b33f41cb..321301bd49c 100755 --- a/regress/usr.bin/ssh/ssh2putty.sh +++ b/regress/usr.bin/ssh/ssh2putty.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: ssh2putty.sh,v 1.5 2019/11/21 05:18:47 tb Exp $ +# $OpenBSD: ssh2putty.sh,v 1.6 2021/05/24 10:25:18 dtucker Exp $ if test "x$1" = "x" -o "x$2" = "x" -o "x$3" = "x" ; then echo "Usage: ssh2putty hostname port ssh-private-key" @@ -17,13 +17,13 @@ if ! grep -q "BEGIN RSA PRIVATE KEY" $KEYFILE ; then fi public_exponent=` - openssl rsa -noout -text -in $KEYFILE | grep ^publicExponent | + $OPENSSL rsa -noout -text -in $KEYFILE | grep ^publicExponent | sed 's/.*(//;s/).*//' ` test $? -ne 0 && exit 1 modulus=` - openssl rsa -noout -modulus -in $KEYFILE | grep ^Modulus= | + $OPENSSL rsa -noout -modulus -in $KEYFILE | grep ^Modulus= | sed 's/^Modulus=/0x/' | tr A-Z a-z ` test $? -ne 0 && exit 1 diff --git a/regress/usr.bin/ssh/test-exec.sh b/regress/usr.bin/ssh/test-exec.sh index 544956cc61c..cadf6dce283 100644 --- a/regress/usr.bin/ssh/test-exec.sh +++ b/regress/usr.bin/ssh/test-exec.sh @@ -1,4 +1,4 @@ -# $OpenBSD: test-exec.sh,v 1.79 2021/04/06 23:57:56 dtucker Exp $ +# $OpenBSD: test-exec.sh,v 1.80 2021/05/24 10:25:18 dtucker Exp $ # Placed in the Public Domain. USER=`id -un` @@ -60,6 +60,7 @@ CONCH=/usr/local/bin/conch # Tools used by multiple tests NC=nc +OPENSSL=openssl if [ "x$TEST_SSH_SSH" != "x" ]; then SSH="${TEST_SSH_SSH}" @@ -103,6 +104,9 @@ fi if [ "x$TEST_SSH_SK_HELPER" != "x" ]; then SSH_SK_HELPER="${TEST_SSH_SK_HELPER}" fi +if [ "x$TEST_SSH_OPENSSL" != "x" ]; then + OPENSSL="${TEST_SSH_OPENSSL}" +fi # Path to sshd must be absolute for rexec case "$SSHD" in -- 2.20.1