@@ -71,16 +71,19 @@ def gen_x25519(keyfile, passwd):
7171}
7272valid_formats = ['openssl' , 'pkcs8' ]
7373
74+
7475def load_signature (sigfile ):
7576 with open (sigfile , 'rb' ) as f :
7677 signature = base64 .b64decode (f .read ())
7778 return signature
7879
80+
7981def save_signature (sigfile , sig ):
8082 with open (sigfile , 'wb' ) as f :
8183 signature = base64 .b64encode (sig )
8284 f .write (signature )
8385
86+
8487def 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' )
128131def 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