@@ -84,6 +84,7 @@ def gen_x25519(keyfile, passwd):
8484}
8585valid_formats = ['openssl' , 'pkcs8' ]
8686valid_sha = [ 'auto' , '256' , '384' , '512' ]
87+ valid_hmac_sha = [ 'auto' , '256' , '512' ]
8788
8889
8990def load_signature (sigfile ):
@@ -437,6 +438,8 @@ def convert(self, value, param, ctx):
437438@click .option ('--sha' , 'user_sha' , type = click .Choice (valid_sha ), default = 'auto' ,
438439 help = 'selected sha algorithm to use; defaults to "auto" which is 256 if '
439440 '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' )
440443@click .option ('--vector-to-sign' , type = click .Choice (['payload' , 'digest' ]),
441444 help = 'send to OUTFILE the payload or payload' 's digest instead '
442445 '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,
449452 endian , encrypt_keylen , encrypt , compression , infile , outfile ,
450453 dependencies , load_addr , hex_addr , erased_val , save_enctlv ,
451454 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 ,
453456 vector_to_sign , non_bootable ):
454457
455458 if confirm :
@@ -526,7 +529,7 @@ def sign(key, public_key_format, align, version, pad_sig, header_size,
526529 img .create (key , public_key_format , enckey , dependencies , boot_record ,
527530 custom_tlvs , compression_tlvs , None , int (encrypt_keylen ), clear ,
528531 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 )
530533 compressed_img = image .Image (version = decode_version (version ),
531534 header_size = header_size , pad_header = pad_header ,
532535 pad = pad , confirm = confirm , align = int (align ),
@@ -570,14 +573,14 @@ def sign(key, public_key_format, align, version, pad_sig, header_size,
570573 compressed_img .create (key , public_key_format , enckey ,
571574 dependencies , boot_record , custom_tlvs , compression_tlvs ,
572575 compression , int (encrypt_keylen ), clear , baked_signature ,
573- pub_key , vector_to_sign , user_sha = user_sha ,
576+ pub_key , vector_to_sign , user_sha = user_sha , hmac_sha = hmac_sha ,
574577 is_pure = is_pure , keep_comp_size = keep_comp_size )
575578 img = compressed_img
576579 else :
577580 img .create (key , public_key_format , enckey , dependencies , boot_record ,
578581 custom_tlvs , compression_tlvs , None , int (encrypt_keylen ), clear ,
579582 baked_signature , pub_key , vector_to_sign , user_sha = user_sha ,
580- is_pure = is_pure )
583+ hmac_sha = hmac_sha , is_pure = is_pure )
581584 img .save (outfile , hex_addr )
582585 if sig_out is not None :
583586 new_signature = img .get_signature ()
0 commit comments