Commit f204d3d
committed
NK3: use device-specific branding and PIN labels consistently across codebase
The NK3 uses 'Secrets app' terminology and has 8 PIN retry attempts (vs 3 for
older devices), but the codebase had inconsistent UX messaging that referred to
'GPG Admin PIN', 'USB security dongle', 'TOKEN', etc. instead of the actual
brand and PIN type.
Fix 1: PIN label - $prompt_message is used in all user-facing strings (status,
prompts, error messages, reminder note) with correct value: 'Secrets app' for NK3,
'GPG Admin' for older devices.
Fix 2: Dynamic attempt counting - after the default PIN trial consumes an attempt,
re-read the counter and limit user attempts to min(retries-1, 3). If the counter
read is unreliable (0 or 1), fall back to 3 attempts so the user is never
blocked from sealing. Documented with example outcomes for NK3 (8 retries) and
pre-NK3 (3 retries).
Fix 3: NK3-specific error message now references 'Secrets app PIN' instead of
'GPG Admin PIN' in the PIN reset instructions.
Fix 4: Use $DONGLE_BRAND consistently in all USB security dongle messaging
(STATUS, prompts, dialog titles, guidance strings, integrity report, DEBUG
logs, error messages, NOTES) instead of hardcoded 'USB security dongle',
'OpenPGP signing card', 'GPG security dongle', 'dongle', 'signing card',
'Dongle key'. Also replaces 'TOKEN' in hotp_state/hotp_display with
$DONGLE_BRAND so integrity report shows actual brand (e.g. 'Nitrokey 3
PRESENT' instead of 'TOKEN PRESENT').
Fix 5: Centralize branding detection in standalone script entry points:
- gui-init.sh: already detects at boot flow entry (line ~965)
- oem-factory-reset.sh: added detection at script start (was missing)
- confirm_gpg_card: detects for gpg-gui.sh and kexec-sign-config.sh
- report_integrity_measurements: detects for hotp/gpg flow
- seal-hotpkey.sh: has its own detection at script start
Fix 6: detect_usb_security_dongle_branding now guards against redundant
re-detection while preserving USB init safety: it skips USB re-init and lsusb
re-scan only when a specific DONGLE_BRAND is already set and _USB_ENABLED=y in
the current process. In child scripts that inherit DONGLE_BRAND but reset
_USB_ENABLED, it still runs enable_usb, then returns without re-scan if
branding is already specific.
Fix 7: Comment casing fix in oem-factory-reset.sh (Secrets App -> Secrets app)
to match user-facing strings and hotp_verification output.
Fix 8: Remove duplicate show_pin_retries call before PIN entry loop in
seal-hotpkey.sh. The function was being called twice before the first prompt
(once before the loop, once at loop start), showing 'Nitrokey 3 Secrets app
PIN retries remaining: 8' twice.
Fix 9: Clarify and enforce fast-path behavior for
detect_usb_security_dongle_branding in mixed parent/child script contexts:
avoid redundant module loads and scans in the same process, but do not skip USB
initialization when only branding is inherited.
Fix 10: detect_usb_security_dongle_branding now reuses wait_for_usb_devices
after enable_usb only when USB was not already initialized in the current
process. This avoids early lsusb enumeration races without regressing the
no-redundant-load/no-re-scan fast path.
Signed-off-by: Thierry Laurion <insurgo@riseup.net>1 parent 38c575f commit f204d3d
5 files changed
Lines changed: 122 additions & 54 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
| 252 | + | |
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
| 256 | + | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
| 295 | + | |
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | | - | |
318 | | - | |
| 317 | + | |
| 318 | + | |
319 | 319 | | |
320 | | - | |
321 | | - | |
| 320 | + | |
| 321 | + | |
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
180 | 184 | | |
181 | 185 | | |
182 | 186 | | |
183 | | - | |
| 187 | + | |
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
| |||
1043 | 1047 | | |
1044 | 1048 | | |
1045 | 1049 | | |
1046 | | - | |
| 1050 | + | |
1047 | 1051 | | |
1048 | 1052 | | |
1049 | 1053 | | |
| |||
1222 | 1226 | | |
1223 | 1227 | | |
1224 | 1228 | | |
1225 | | - | |
| 1229 | + | |
1226 | 1230 | | |
1227 | 1231 | | |
1228 | 1232 | | |
| |||
1320 | 1324 | | |
1321 | 1325 | | |
1322 | 1326 | | |
1323 | | - | |
| 1327 | + | |
1324 | 1328 | | |
1325 | 1329 | | |
1326 | | - | |
| 1330 | + | |
1327 | 1331 | | |
1328 | 1332 | | |
1329 | 1333 | | |
| |||
1605 | 1609 | | |
1606 | 1610 | | |
1607 | 1611 | | |
1608 | | - | |
| 1612 | + | |
1609 | 1613 | | |
1610 | 1614 | | |
1611 | 1615 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| 107 | + | |
| 108 | + | |
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
| |||
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
116 | | - | |
| 119 | + | |
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
| |||
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
134 | | - | |
| 137 | + | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
| |||
144 | 147 | | |
145 | 148 | | |
146 | 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 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
147 | 188 | | |
148 | 189 | | |
149 | | - | |
| 190 | + | |
150 | 191 | | |
151 | 192 | | |
152 | | - | |
| 193 | + | |
153 | 194 | | |
154 | | - | |
| 195 | + | |
155 | 196 | | |
156 | 197 | | |
157 | 198 | | |
158 | 199 | | |
159 | | - | |
| 200 | + | |
160 | 201 | | |
161 | 202 | | |
162 | 203 | | |
163 | | - | |
164 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
165 | 209 | | |
166 | 210 | | |
167 | | - | |
| 211 | + | |
168 | 212 | | |
169 | 213 | | |
170 | | - | |
| 214 | + | |
171 | 215 | | |
172 | 216 | | |
173 | 217 | | |
174 | 218 | | |
175 | 219 | | |
176 | 220 | | |
177 | 221 | | |
178 | | - | |
| 222 | + | |
179 | 223 | | |
180 | 224 | | |
181 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
503 | 519 | | |
504 | 520 | | |
505 | 521 | | |
| |||
644 | 660 | | |
645 | 661 | | |
646 | 662 | | |
647 | | - | |
| 663 | + | |
648 | 664 | | |
649 | 665 | | |
650 | 666 | | |
| |||
831 | 847 | | |
832 | 848 | | |
833 | 849 | | |
| 850 | + | |
| 851 | + | |
834 | 852 | | |
835 | 853 | | |
836 | 854 | | |
| |||
0 commit comments