]> Dogcows Code - chaz/p5-File-KDBX/blob - t/files/bin/ykchalresp
7cac1f5fd409a930eadaff2ddc2332e8f2da6f39
[chaz/p5-File-KDBX] / t / files / bin / ykchalresp
1 #!/bin/sh
2
3 # This is a fake ykchalresp program that provides canned responses, for testing.
4
5 device=
6 slot=
7 blocking=1
8 hmac=
9 in=
10
11 while getopts 12HNn:i: arg
12 do
13 case "$arg" in
14 n)
15 device="$OPTARG"
16 ;;
17 1)
18 slot=1
19 ;;
20 2)
21 slot=2
22 ;;
23 H)
24 hmac=1
25 ;;
26 N)
27 blocking=0
28 ;;
29 i)
30 in="$OPTARG"
31 ;;
32 esac
33 done
34
35 if [ -z "$hmac" ]
36 then
37 echo 'HMAC-SHA1 not requested' >&2
38 exit 3
39 fi
40
41 if [ "$in" != '-' ]
42 then
43 echo "Unexpected input file: $in" >&2
44 exit 3
45 fi
46
47 read challenge
48
49 succeed() {
50 echo "${YKCHALRESP_RESPONSE:-f000000000000000000000000000000000000000}"
51 exit 0
52 }
53
54 case "$YKCHALRESP_MOCK" in
55 block)
56 if [ "$blocking" -eq 0 ]
57 then
58 echo "Yubikey core error: operation would block" >&2
59 exit 1
60 fi
61 sleep 2
62 succeed
63 ;;
64 error)
65 echo "Yubikey core error: ${YKCHALRESP_ERROR:-not yet implemented}" >&2
66 exit 1
67 ;;
68 usberror)
69 echo "USB error: something happened" >&2
70 exit 1
71 ;;
72 *) # OK
73 succeed
74 ;;
75 esac
76 exit 2
This page took 0.034828 seconds and 3 git commands to generate.