Vendor HID for upgrades (#529)

* vendor-hid for upgrades

* empty argument fix

* same vendor-hid usage in both deploys

* forgot one board

* aaand also forgot the quotes
This commit is contained in:
kaczmarczyck
2022-08-17 10:29:26 +02:00
committed by GitHub
parent 87839af572
commit 4442998b64
4 changed files with 30 additions and 5 deletions

View File

@@ -25,6 +25,7 @@ import hashlib
import os
import struct
from typing import Any
from unittest.mock import patch
import uuid
import colorama
@@ -172,7 +173,16 @@ def main(args):
"signature": sign_firmware(signed_data, priv_key)
}
for authenticator in tqdm(get_opensk_devices(args.batch)):
if args.use_vendor_hid:
patcher = patch.object(hid.base, "FIDO_USAGE_PAGE", 0xFF00)
patcher.start()
info("Using the Vendor HID interface")
devices = get_opensk_devices(args.batch)
if not devices:
fatal("No devices found.")
for authenticator in tqdm(devices):
# If the device supports it, wink to show which device we upgrade.
if authenticator.device.capabilities & hid.CAPABILITY.WINK:
authenticator.device.wink()
@@ -242,4 +252,11 @@ if __name__ == "__main__":
dest="priv_key",
help=("PEM file for signing the firmware."),
)
parser.add_argument(
"--vendor-hid",
default=False,
action="store_true",
dest="use_vendor_hid",
help=("Whether to upgrade the device using the Vendor HID interface."),
)
main(parser.parse_args())