1111 ML_KEM_1024_NAME ,
1212 ML_DSA_87_NAME ,
1313 CLASSIC_MCELIECE_8_F_NAME ,
14- CLASSIC_MCELIECE_8_F_ROTATE_AT
14+ CLASSIC_MCELIECE_8_F_ROTATE_AT ,
15+ KEYS_HASH_CHAIN_LEN
1516)
1617from core .trad_crypto import sha3_512
1718from base64 import b64encode , b64decode
@@ -39,7 +40,7 @@ def send_new_ephemeral_keys(user_data, user_data_lock, contact_id, ui_queue) ->
3940 if not user_data_copied ["contacts" ][contact_id ]["lt_sign_keys" ]["our_hash_chain" ]:
4041 with user_data_lock :
4142 # Set up the hash chain's initial seed
42- user_data ["contacts" ][contact_id ]["lt_sign_keys" ]["our_hash_chain" ] = secrets .token_bytes (64 )
43+ user_data ["contacts" ][contact_id ]["lt_sign_keys" ]["our_hash_chain" ] = secrets .token_bytes (KEYS_HASH_CHAIN_LEN )
4344
4445 our_hash_chain = user_data ["contacts" ][contact_id ]["lt_sign_keys" ]["our_hash_chain" ]
4546 else :
@@ -157,7 +158,7 @@ def pfs_data_handler(user_data, user_data_lock, user_data_copied, ui_queue, mess
157158 logger .error ("contact (%s) sent message of unknown pfs_type (%s)" , contact_id , message ["pfs_type" ])
158159 return
159160
160- contact_hash_chain = contact_publickeys_hashchain [:64 ]
161+ contact_hash_chain = contact_publickeys_hashchain [:KEYS_HASH_CHAIN_LEN ]
161162
162163 # If we do not have a hashchain for the contact, we don't need to compute the chain, just save.
163164 if not user_data_copied ["contacts" ][contact_id ]["lt_sign_keys" ]["contact_hash_chain" ]:
@@ -172,11 +173,11 @@ def pfs_data_handler(user_data, user_data_lock, user_data_copied, ui_queue, mess
172173 logger .error ("Contact hash chain does not match our computed hash chain, we are skipping this PFS message..." )
173174 return
174175
175- contact_kyber_public_key = contact_publickeys_hashchain [64 : ALGOS_BUFFER_LIMITS [ML_KEM_1024_NAME ]["PK_LEN" ] + 64 ]
176+ contact_kyber_public_key = contact_publickeys_hashchain [KEYS_HASH_CHAIN_LEN : ALGOS_BUFFER_LIMITS [ML_KEM_1024_NAME ]["PK_LEN" ] + KEYS_HASH_CHAIN_LEN ]
176177 if message ["pfs_type" ] == "full" :
177178 logger .info ("contact (%s) has rotated their Kyber and McEliece keys" , contact_id )
178179
179- contact_mceliece_public_key = contact_publickeys_hashchain [ALGOS_BUFFER_LIMITS [ML_KEM_1024_NAME ]["PK_LEN" ] + 64 :]
180+ contact_mceliece_public_key = contact_publickeys_hashchain [ALGOS_BUFFER_LIMITS [ML_KEM_1024_NAME ]["PK_LEN" ] + KEYS_HASH_CHAIN_LEN :]
180181 with user_data_lock :
181182 user_data ["contacts" ][contact_id ]["ephemeral_keys" ]["contact_public_keys" ][CLASSIC_MCELIECE_8_F_NAME ] = contact_mceliece_public_key
182183
0 commit comments