Skip to content

Commit

Permalink
Merge pull request #1800 from jku/document-serialization-hash-issue
Browse files Browse the repository at this point in the history
Metadata API: Document serialization "repro" issue
  • Loading branch information
lukpueh authored Feb 7, 2022
2 parents 8a0bb88 + 3f3b921 commit 70c7358
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tuf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ def to_bytes(
) -> bytes:
"""Return the serialized TUF file format as bytes.
Note that if bytes are first deserialized into ``Metadata`` and then
serialized with ``to_bytes()``, the two are not required to be
identical even though the signatures are guaranteed to stay valid. If
byte-for-byte equivalence is required (which is the case when content
hashes are used in other metadata), the original content should be used
instead of re-serializing.
Arguments:
serializer: A MetadataSerializer instance that implements the
desired serialization format. Default is JSONSerializer.
Expand Down Expand Up @@ -265,6 +272,13 @@ def to_file(
) -> None:
"""Writes TUF metadata to file storage.
Note that if a file is first deserialized into ``Metadata`` and then
serialized with ``to_file()``, the two files are not required to be
identical even though the signatures are guaranteed to stay valid. If
byte-for-byte equivalence is required (which is the case when file
hashes are used in other metadata), the original file should be used
instead of re-serializing.
Arguments:
filename: The path to write the file to.
serializer: A MetadataSerializer instance that implements the
Expand Down

0 comments on commit 70c7358

Please sign in to comment.