Documentation
¶
Overview ¶
Package checksum implements the client-visible checksums S3 exposes as x-amz-checksum-*.
This is a *second* checksum, distinct from the content MD5 behind ETag and from the integrity checksum the scrubber uses. It has its own algorithms, its own negotiation, and its own composition rule for multipart objects, and conflating it with either of the others is the mistake this package exists to make hard: the ETag is a property of how the object was stored, while this is a digest the *client* chose, sent, and expects back unchanged.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompositeOf ¶
CompositeOf computes a multipart object's COMPOSITE checksum: the digest of the concatenated *raw part digests*, with the part count appended after a dash.
The "-N" suffix is not decoration. It is the only thing in the value that says "this is not a digest of the object's bytes" — a client that fed the object back through the same algorithm would get something else entirely, and the suffix is what stops that being a mystery.
Parts must be in ascending part-number order, which is the order they are concatenated in and therefore the order the digest depends on.
Types ¶
type Algorithm ¶
type Algorithm string
Algorithm is one of the checksum algorithms S3 defines. The zero value means no checksum was requested.
const ( CRC32 Algorithm = "CRC32" CRC32C Algorithm = "CRC32C" CRC64NVME Algorithm = "CRC64NVME" SHA1 Algorithm = "SHA1" SHA256 Algorithm = "SHA256" )
The algorithms S3 accepts, spelled as they appear on the wire.
func (Algorithm) Decode ¶
Decode reads a digest a client sent, and reports whether it is well-formed for the algorithm.
A digest of the wrong length is rejected here rather than compared and found unequal, so "you sent nonsense" and "your bytes did not match" stay distinguishable.
func (Algorithm) DefaultType ¶
DefaultType is the checksum type S3 uses when a multipart upload names an algorithm but no type.
func (Algorithm) SupportsFullObject ¶
SupportsFullObject reports whether the algorithm can produce a FULL_OBJECT multipart checksum. Only the CRCs can: combining two of them yields the CRC of the concatenation, which is what makes a whole-object digest computable from parts without re-reading the object.
type Type ¶
type Type string
Type is how a multipart object's checksum relates to its parts.
const ( // Composite is a digest *of the part digests*, which is why its value // carries a "-N" suffix naming the part count: it is not a digest of the // object's bytes and must not be mistaken for one. Composite Type = "COMPOSITE" // FullObject is a digest of the whole body, as if it had been written by a // single PUT. Only the CRCs support it, because only they compose: two // CRCs can be combined into the CRC of the concatenation, and two SHAs // cannot. FullObject Type = "FULL_OBJECT" )