mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2026-01-17 01:18:06 +00:00
Add reboot extra command.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
a242a28394
commit
866aac8fe3
2 changed files with 17 additions and 0 deletions
|
|
@ -19,6 +19,7 @@
|
|||
#include "mbedtls/ecdh.h"
|
||||
#ifdef PICO_PLATFORM
|
||||
#include "pico/aon_timer.h"
|
||||
#include "hardware/watchdog.h"
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
|
@ -35,6 +36,7 @@
|
|||
#define CMD_DATETIME 0xA
|
||||
#define CMD_DYNOPS 0x6
|
||||
#define CMD_SECURE_LOCK 0x3A
|
||||
#define CMD_REBOOT 0xFB
|
||||
#define SECURE_LOCK_KEY_AGREEMENT 0x1
|
||||
#define SECURE_LOCK_ENABLE 0x2
|
||||
#define SECURE_LOCK_MASK 0x3
|
||||
|
|
@ -287,6 +289,14 @@ int cmd_extras() {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef PICO_PLATFORM
|
||||
else if (P1(apdu) == CMD_REBOOT) {
|
||||
if (apdu.nc != 0) {
|
||||
return SW_WRONG_LENGTH();
|
||||
}
|
||||
watchdog_reboot(0, 0, 100);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
return SW_INCORRECT_P1P2();
|
||||
|
|
|
|||
|
|
@ -149,6 +149,8 @@ def parse_args():
|
|||
parser_otp.add_argument('--lock', help='Lock & protect (no other firmwares can be loaded)', action='store_true')
|
||||
parser_otp.add_argument('--index', help='Bootkey index [0-3]', type=int, default=0, choices=[0, 1, 2, 3])
|
||||
|
||||
parser_reboot = subparser.add_parser('reboot', help='Reboots the Pico HSM.')
|
||||
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
|
@ -507,6 +509,9 @@ def otp(picohsm, args):
|
|||
elif (args.subcommand == 'secure_boot'):
|
||||
picohsm.secure_boot(BOOTKEY, bootkey_index=args.index, lock=args.lock)
|
||||
|
||||
def reboot(picohsm, args):
|
||||
picohsm.reboot()
|
||||
|
||||
def main(args):
|
||||
sys.stderr.buffer.write(b'Pico HSM Tool v2.0\n')
|
||||
sys.stderr.buffer.write(b'Author: Pol Henarejos\n')
|
||||
|
|
@ -537,6 +542,8 @@ def main(args):
|
|||
phy(picohsm, args)
|
||||
elif (args.command == 'otp'):
|
||||
otp(picohsm, args)
|
||||
elif (args.command == 'reboot'):
|
||||
reboot(picohsm, args)
|
||||
|
||||
def run():
|
||||
args = parse_args()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue