@@ -627,8 +627,7 @@ def __check_hashes(self, file_object, trusted_hashes):
627627 digest_object .update (file_object .read ())
628628 computed_hash = digest_object .hexdigest ()
629629 if trusted_hash != computed_hash :
630- raise tuf .BadHashError ('Hashes do not match! Expected ' +
631- trusted_hash + ' got ' + computed_hash )
630+ raise tuf .BadHashError (trusted_hash , computed_hash )
632631 else :
633632 logger .info ('The file\' s ' + algorithm + ' hash is correct: ' + trusted_hash )
634633
@@ -835,7 +834,7 @@ def __verify_uncompressed_metadata_file(self, metadata_file_object,
835834 # Verify the signature on the downloaded metadata object.
836835 valid = tuf .sig .verify (metadata_signable , metadata_role )
837836 if not valid :
838- raise tuf .BadSignatureError ()
837+ raise tuf .BadSignatureError (metadata_role )
839838
840839
841840
@@ -1742,10 +1741,11 @@ def _ensure_not_expired(self, metadata_role):
17421741 # an exception. 'expires' is in YYYY-MM-DD HH:MM:SS format, so
17431742 # convert it to seconds since the epoch, which is the time format
17441743 # returned by time.time() (i.e., current time), before comparing.
1745- if tuf .formats .parse_time (expires ) < time .time ():
1746- message = 'Metadata ' + repr (rolepath )+ ' expired on ' + repr (expires )+ '.'
1747- logger .error (message )
1748- raise tuf .ExpiredMetadataError (message )
1744+ current_time = time .time ()
1745+ expiry_time = tuf .formats .parse_time (expires )
1746+ if expiry_time < current_time :
1747+ logger .error ('Metadata ' + repr (rolepath )+ ' expired on ' + repr (expires )+ '.' )
1748+ raise tuf .ExpiredMetadataError (expires )
17491749
17501750
17511751
0 commit comments