Skip to content

Commit 5985253

Browse files
committed
imgtool: add key password support
Imgtool can sign a binary for multiple boards, which requires the use of multiple key pairs. To simplify the automation of this process, a key password argument is added. Signed-off-by: Maxime Méré <[email protected]>
1 parent 461e060 commit 5985253

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scripts/imgtool/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,16 @@ def save_signature(sigfile, sig):
9999
f.write(signature)
100100

101101

102-
def load_key(keyfile):
102+
def load_key(keyfile, passwd=None):
103103
# TODO: better handling of invalid pass-phrase
104104
key = keys.load(keyfile)
105105
if key is not None:
106106
return key
107-
passwd = getpass.getpass("Enter key passphrase: ").encode('utf-8')
108-
return keys.load(keyfile, passwd)
109107

108+
if passwd is None:
109+
passwd = getpass.getpass("Enter key passphrase: ")
110+
111+
return keys.load(keyfile, passwd.encode('utf-8'))
110112

111113
def get_password():
112114
while True:

0 commit comments

Comments
 (0)