@@ -84,6 +84,7 @@ def gen_x25519(keyfile, passwd):
84
84
}
85
85
valid_formats = ['openssl' , 'pkcs8' ]
86
86
valid_sha = [ 'auto' , '256' , '384' , '512' ]
87
+ valid_hmac_sha = [ 'auto' , '256' , '512' ]
87
88
88
89
89
90
def load_signature (sigfile ):
@@ -437,6 +438,8 @@ def convert(self, value, param, ctx):
437
438
@click .option ('--sha' , 'user_sha' , type = click .Choice (valid_sha ), default = 'auto' ,
438
439
help = 'selected sha algorithm to use; defaults to "auto" which is 256 if '
439
440
'no cryptographic signature is used, or default for signature type' )
441
+ @click .option ('--hmac-sha' , 'hmac_sha' , type = click .Choice (valid_hmac_sha ), default = 'auto' ,
442
+ help = 'sha algorithm used in HKDF/HMAC in ECIES key exchange TLV' )
440
443
@click .option ('--vector-to-sign' , type = click .Choice (['payload' , 'digest' ]),
441
444
help = 'send to OUTFILE the payload or payload' 's digest instead '
442
445
'of complied image. These data can be used for external image '
@@ -449,7 +452,7 @@ def sign(key, public_key_format, align, version, pad_sig, header_size,
449
452
endian , encrypt_keylen , encrypt , compression , infile , outfile ,
450
453
dependencies , load_addr , hex_addr , erased_val , save_enctlv ,
451
454
security_counter , boot_record , custom_tlv , rom_fixed , max_align ,
452
- clear , fix_sig , fix_sig_pubkey , sig_out , user_sha , is_pure ,
455
+ clear , fix_sig , fix_sig_pubkey , sig_out , user_sha , hmac_sha , is_pure ,
453
456
vector_to_sign , non_bootable ):
454
457
455
458
if confirm :
@@ -526,7 +529,7 @@ def sign(key, public_key_format, align, version, pad_sig, header_size,
526
529
img .create (key , public_key_format , enckey , dependencies , boot_record ,
527
530
custom_tlvs , compression_tlvs , None , int (encrypt_keylen ), clear ,
528
531
baked_signature , pub_key , vector_to_sign , user_sha = user_sha ,
529
- is_pure = is_pure , keep_comp_size = False , dont_encrypt = True )
532
+ hmac_sha = hmac_sha , is_pure = is_pure , keep_comp_size = False , dont_encrypt = True )
530
533
compressed_img = image .Image (version = decode_version (version ),
531
534
header_size = header_size , pad_header = pad_header ,
532
535
pad = pad , confirm = confirm , align = int (align ),
@@ -568,14 +571,14 @@ def sign(key, public_key_format, align, version, pad_sig, header_size,
568
571
compressed_img .create (key , public_key_format , enckey ,
569
572
dependencies , boot_record , custom_tlvs , compression_tlvs ,
570
573
compression , int (encrypt_keylen ), clear , baked_signature ,
571
- pub_key , vector_to_sign , user_sha = user_sha ,
574
+ pub_key , vector_to_sign , user_sha = user_sha , hmac_sha = hmac_sha ,
572
575
is_pure = is_pure , keep_comp_size = keep_comp_size )
573
576
img = compressed_img
574
577
else :
575
578
img .create (key , public_key_format , enckey , dependencies , boot_record ,
576
579
custom_tlvs , compression_tlvs , None , int (encrypt_keylen ), clear ,
577
580
baked_signature , pub_key , vector_to_sign , user_sha = user_sha ,
578
- is_pure = is_pure )
581
+ hmac_sha = hmac_sha , is_pure = is_pure )
579
582
img .save (outfile , hex_addr )
580
583
if sig_out is not None :
581
584
new_signature = img .get_signature ()
0 commit comments