forked from Nitrokey/pynitrokey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interactive_test.sh
executable file
·183 lines (132 loc) · 3.8 KB
/
interactive_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/bash
npy=venv/bin/nitropy
function make_title
{
if [[ "$2" = "" ]]; then
echo "------------------------------------------------------------------------"
echo "-> $1"
else
echo "########################################################################"
echo "########################################################################"
echo "## $1"
fi
if [[ "$2" != "" ]]; then
echo "## $2"
[[ "$NO_WAIT" = "" ]] && echo -n ">> press enter to continue... " && read foo
fi
}
function askout
{
[[ "$NO_WAIT" = "" ]] && echo -n "<<<<<<<<<<< stop? " && read inp
if [[ "$inp" = "y" ]]; then
exit 1;
fi
}
function run
{
echo
echo ">>>>>>>>>>> " $npy "$@"
$npy "$@"
askout
}
function testfido2
{
make_title "Testing Nitrokey - FIDO2" \
"Please insert a Nitrokey FIDO2 (will be wiped!)"
make_title "Simple listing of device(s)"
run ls
run fido2 list
make_title "resetting and set pin"
# hrm ...
#echo -ne "1234\n1234\n" > set_pin.txt
#echo -ne "1234\n123456\n123456\n" > change_pin.txt
run fido2 reset
run fido2 set-pin
echo "make sure pin is finally: 123456"
run fido2 change-pin
run fido2 verify
#--pin 123456
make_title "create a credential + challenge-response using it"
run fido2 make-credential
echo "press again..."
out=`${npy} fido2 make-credential | tail -n 1`
echo key $out
run fido2 challenge-response $out my_challenge
make_title "reboot, version, verify, update, verify, reset, version"
run fido2 reboot
echo "sleeping for 5secs..."
sleep 5
run fido2 version
run fido2 verify
run fido2 update
run fido2 verify
run fido2 reset
run fido2 version
make_title "rng subcommand(s)"
run fido2 rng hexbytes
run fido2 rng hexbytes --count 12
echo "SKIP: sudo run fido2 rng feedkernel"
echo "SKIP: run fido2 rng raw"
make_title "wink, reboot, wink, reboot, reset, set-pin, change-pin, verify"
run fido2 wink
run fido2 reboot
sleep 5
run fido2 wink
run fido2 reboot
sleep 5
make_title "finally one more reset and then verify"
run fido2 reset
run fido2 verify
make_title "get .hex firmware, gen sign-key, sign, (skipped: flash bad fw), flash good fw"
wget "https://github.com/Nitrokey/nitrokey-fido2-firmware/releases/download/2.0.0.nitrokey/nitrokey-fido2-firmware-2.0.0-app-to_sign.hex"
run fido2 util genkey test_key.pem
run fido2 util sign test_key.pem nitrokey-fido2-firmware-2.0.0-app-to_sign.hex output.json
#echo "###>>>> THIS ONE WILL FAIL, EXPECTED FAIL:"
#run fido2 util program bootloader output.json
#sleep 1
wget "https://github.com/Nitrokey/nitrokey-fido2-firmware/releases/download/2.1.0.nitrokey/nitrokey-fido2-firmware-2.1.0.json"
echo "###>>>> THIS ONE MUST WORK - if not: brick!? :D"
run fido2 util program bootloader nitrokey-fido2-firmware-2.1.0.json
sleep 1
make_title "util program aux enter-bootloader, show version, leave + lists & reboots after each"
run fido2 util program aux enter-bootloader
sleep 1
run fido2 list
run fido2 util program aux bootloader-version
run fido2 util program aux reboot
echo "longer sleep"
sleep 5
run fido2 list
run fido2 util program aux leave-bootloader
sleep 5
run fido2 list
run fido2 reboot
sleep 1
run fido2 list
}
function teststart
{
make_title "Testing Nitrokey - Start" \
"Please insert a Nitrokey Start (will be wiped!)"
make_title "Simple listing of devices"
run ls
run start list
make_title "setting identity 0, 1, 2, 0"
run start set-identity 0
run start set-identity 1
run start set-identity 2
run start set-identity 0
make_title "updating with latest firmware"
run start update
make_title "setting identity 2, 0, 1, 0"
run start set-identity 2
run start set-identity 0
run start set-identity 1
run start set-identity 0
}
if [[ "$1" = "" ]] || [[ "$1" = "fido2" ]]; then
testfido2
fi
if [[ "$1" = "" ]] || [[ "$1" = "start" ]]; then
teststart
fi