]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - t/files/bin/ykchalresp
add initial WIP
[chaz/p5-File-KDBX] / t / files / bin / ykchalresp
diff --git a/t/files/bin/ykchalresp b/t/files/bin/ykchalresp
new file mode 100755 (executable)
index 0000000..7cac1f5
--- /dev/null
@@ -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
This page took 0.020893 seconds and 4 git commands to generate.