Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mistake in pico-hsm-tool.py #25

Closed
fchaxel opened this issue Jun 20, 2023 · 3 comments
Closed

mistake in pico-hsm-tool.py #25

fchaxel opened this issue Jun 20, 2023 · 3 comments

Comments

@fchaxel
Copy link

fchaxel commented Jun 20, 2023

Hi all,

Very good job ... an HSM module for 4 euros !

Line 114 it should be
parser._init.add_argument('--pin', help='PIN number')
not
parser.add_argument('--pin', help='PIN number')

Line 131 it should be
parser_rtc_get = subparser_rtc.add_parser('get', help='Gets the current datetime.')
not
parser_rtc_get = subparser_rtc.add_parser('set', help='Gets the current datetime.')

bye

@polhenarejos
Copy link
Owner

parser.add_argument('--pin', help='PIN number') is correct. --pin argument is available not only for initialization, but also for other commands. It is a common parameter for all.

Fixed rtc_get.

@fchaxel
Copy link
Author

fchaxel commented Jun 20, 2023

So in https://github.com/polhenarejos/pico-hsm/blob/master/doc/usage.md

$ python3 pico-hsm-tool.py initialize --so-pin 3537363231383830 --pin 648219

should be

$ python3 pico-hsm-tool.py --pin 648219 initialize --so-pin 3537363231383830

at the end of the command line --pin generates an error

HSM module work like a charm with XCA tool on Windows.

Bye

@fchaxel
Copy link
Author

fchaxel commented Jun 22, 2023

Hi,

Back again with def parse_args(): in the script

In order to get the --pin args to be place after the command, and to use it with several sub command one can write something like this :

subparser = parser.add_subparsers(title="commands", dest="command")
parent = argparse.ArgumentParser(add_help=False)
parent.add_argument('--pin', help='PIN number')
parser_init = subparser.add_parser('initialize', help='Performs the first initialization of the Pico HSM.',parents=[parent])
parser_init.add_argument('--so-pin', help='SO-PIN number')  

And you have to add the parameter parents=[parent] in each subcommand where the --pin argument can be use.

Bye.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants