X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=t%2Ffiles%2Fbin%2Fykchalresp;fp=t%2Ffiles%2Fbin%2Fykchalresp;h=7cac1f5fd409a930eadaff2ddc2332e8f2da6f39;hb=f63182fc62b25269b1c38588dca2b3535ed1a1a2;hp=0000000000000000000000000000000000000000;hpb=e2deca75a6040911441e0d7c4430aeae9be69e40;p=chaz%2Fp5-File-KDBX diff --git a/t/files/bin/ykchalresp b/t/files/bin/ykchalresp new file mode 100755 index 0000000..7cac1f5 --- /dev/null +++ b/t/files/bin/ykchalresp @@ -0,0 +1,76 @@ +#!/bin/sh + +# This is a fake ykchalresp program that provides canned responses, for testing. + +device= +slot= +blocking=1 +hmac= +in= + +while getopts 12HNn:i: arg +do + case "$arg" in + n) + device="$OPTARG" + ;; + 1) + slot=1 + ;; + 2) + slot=2 + ;; + H) + hmac=1 + ;; + N) + blocking=0 + ;; + i) + in="$OPTARG" + ;; + esac +done + +if [ -z "$hmac" ] +then + echo 'HMAC-SHA1 not requested' >&2 + exit 3 +fi + +if [ "$in" != '-' ] +then + echo "Unexpected input file: $in" >&2 + exit 3 +fi + +read challenge + +succeed() { + echo "${YKCHALRESP_RESPONSE:-f000000000000000000000000000000000000000}" + exit 0 +} + +case "$YKCHALRESP_MOCK" in + block) + if [ "$blocking" -eq 0 ] + then + echo "Yubikey core error: operation would block" >&2 + exit 1 + fi + sleep 2 + succeed + ;; + error) + echo "Yubikey core error: ${YKCHALRESP_ERROR:-not yet implemented}" >&2 + exit 1 + ;; + usberror) + echo "USB error: something happened" >&2 + exit 1 + ;; + *) # OK + succeed + ;; +esac +exit 2