Skip to content

Commit 7ba01c0

Browse files
adeaarmutzig
authored andcommitted
imgtool: Fix PEP8 warnings on modules in this PR
Fix the remaining PEP8 warnings that appear on image.py, ecdsa.py or main.py for imgtool. Signed-off-by: Antonio de Angelis <[email protected]>
1 parent c6e7e9b commit 7ba01c0

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

scripts/imgtool/keys/ecdsa.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212

1313
from .general import KeyClass
1414

15+
1516
class ECDSAUsageError(Exception):
1617
pass
1718

19+
1820
class ECDSA256P1Public(KeyClass):
1921
def __init__(self, key):
2022
self.key = key
@@ -160,7 +162,8 @@ def get_private_bytes(self, minimal, format):
160162
return priv
161163

162164
def export_private(self, path, passwd=None):
163-
"""Write the private key to the given file, protecting it with the optional password."""
165+
"""Write the private key to the given file, protecting it with '
166+
'the optional password."""
164167
if passwd is None:
165168
enc = serialization.NoEncryption()
166169
else:

scripts/imgtool/main.py

100644100755
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,19 @@ def gen_x25519(keyfile, passwd):
7171
}
7272
valid_formats = ['openssl', 'pkcs8']
7373

74+
7475
def load_signature(sigfile):
7576
with open(sigfile, 'rb') as f:
7677
signature = base64.b64decode(f.read())
7778
return signature
7879

80+
7981
def save_signature(sigfile, sig):
8082
with open(sigfile, 'wb') as f:
8183
signature = base64.b64encode(sig)
8284
f.write(signature)
8385

86+
8487
def load_key(keyfile):
8588
# TODO: better handling of invalid pass-phrase
8689
key = keys.load(keyfile)
@@ -127,7 +130,8 @@ def keygen(type, key, password):
127130
@click.command(help='Dump public key from keypair')
128131
def getpub(key, encoding, lang):
129132
if encoding and lang:
130-
raise click.UsageError('Please use only one of `--encoding/-e` or `--lang/-l`')
133+
raise click.UsageError('Please use only one of `--encoding/-e` '
134+
'or `--lang/-l`')
131135
elif not encoding and not lang:
132136
# Preserve old behavior defaulting to `c`. If `lang` is removed,
133137
# `default=valid_encodings[0]` should be added to `-e` param.
@@ -281,7 +285,7 @@ def convert(self, value, param, ctx):
281285
help='Encrypt image using the provided public key. '
282286
'(Not supported in direct-xip or ram-load mode.)')
283287
@click.option('--encrypt-keylen', default='128',
284-
type=click.Choice(['128','256']),
288+
type=click.Choice(['128', '256']),
285289
help='When encrypting the image using AES, select a 128 bit or '
286290
'256 bit key len.')
287291
@click.option('-c', '--clear', required=False, is_flag=True, default=False,
@@ -342,8 +346,8 @@ def convert(self, value, param, ctx):
342346
help='Path to the file to which signature will be written. '
343347
'The image signature will be encoded as base64 formatted string')
344348
@click.option('--vector-to-sign', type=click.Choice(['payload', 'digest']),
345-
help='send to OUTFILE the payload or payload''s digest instead of '
346-
'complied image. These data can be used for external image '
349+
help='send to OUTFILE the payload or payload''s digest instead '
350+
'of complied image. These data can be used for external image '
347351
'signing')
348352
@click.command(help='''Create a signed or unsigned image\n
349353
INFILE and OUTFILE are parsed as Intel HEX if the params have
@@ -407,18 +411,18 @@ def sign(key, public_key_format, align, version, pad_sig, header_size,
407411

408412
if raw_signature is not None:
409413
if fix_sig_pubkey is None:
410-
raise click.UsageError(
414+
raise click.UsageError(
411415
'public key of the fixed signature is not specified')
412416

413417
pub_key = load_key(fix_sig_pubkey)
414418

415419
baked_signature = {
416-
'value' : raw_signature
420+
'value': raw_signature
417421
}
418422

419423
img.create(key, public_key_format, enckey, dependencies, boot_record,
420-
custom_tlvs, int(encrypt_keylen), clear, baked_signature, pub_key,
421-
vector_to_sign)
424+
custom_tlvs, int(encrypt_keylen), clear, baked_signature,
425+
pub_key, vector_to_sign)
422426
img.save(outfile, hex_addr)
423427

424428
if sig_out is not None:

0 commit comments

Comments
 (0)