Skip to content

Commit a2d23a6

Browse files
authored
doc(storage): fix hashing options documentation (#7033)
1 parent 61f05b2 commit a2d23a6

1 file changed

Lines changed: 37 additions & 26 deletions

File tree

google/cloud/storage/hashing_options.h

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ namespace cloud {
2424
namespace storage {
2525
inline namespace STORAGE_CLIENT_NS {
2626
/**
27-
* Provide a pre-computed MD5 hash value to an upload or download request.
27+
* Provide a pre-computed MD5 hash value.
2828
*
29-
* The application may know what the MD5 hash value of a particular object is,
30-
* for example, because it was downloaded from GCS or some other cloud storage
31-
* service. In these cases, the client can include the hash value in the
32-
* request for better end-to-end validation.
29+
* The application may be able to obtain a MD5 hash in some out-of-band way.
30+
* For example, if the object was downloaded from some other cloud storage
31+
* service, or because the application already queried the GCS object metadata.
32+
* In these cases, providing the value to the client library improves the
33+
* end-to-end data integrity verification.
34+
*
35+
* @see
36+
* https://sigops.org/s/conferences/hotos/2021/papers/hotos21-s01-hochschild.pdf
3337
*/
3438
struct MD5HashValue
3539
: public internal::ComplexOption<MD5HashValue, std::string> {
@@ -48,13 +52,14 @@ std::string ComputeMD5Hash(std::string const& payload);
4852
/**
4953
* Disable or enable MD5 Hashing computations.
5054
*
51-
* By default MD5 Hashing computations is disabled.
52-
* Default constructor DisableMD5Hash() also disables MD5 Hashing computations.
53-
* You must explicitly pass `EnableMD5Hash()` to enable MD5Hash.
55+
* By default MD5 hashes are disabled. To enable them use the
56+
* `EnableMD5Hash()` helper function.
5457
*
55-
* @warning Disabling MD5 hashing and Crc32cChecksum at the same time exposes
56-
* your application to data corruption. We recommend that all uploads to GCS
57-
* are protected by the supported checksums and/or hashes.
58+
* @warning MD5 hashes are disabled by default, as they are computationally
59+
* expensive, and CRC32C checksums provide enough data integrity protection
60+
* for most applications. Disabling CRC32C checksums while MD5 hashes remain
61+
* disabled exposes your application to data corruption. We recommend that all
62+
* uploads to GCS and downloads from GCS use CRC32C checksums.
5863
*/
5964
struct DisableMD5Hash : public internal::ComplexOption<DisableMD5Hash, bool> {
6065
using ComplexOption<DisableMD5Hash, bool>::ComplexOption;
@@ -65,20 +70,24 @@ struct DisableMD5Hash : public internal::ComplexOption<DisableMD5Hash, bool> {
6570
};
6671

6772
/**
68-
* Enable MD5 Hashing computations.
73+
* Enable MD5 hashes in upload and download operations.
6974
*
7075
* Use this function where the option `DisableMD5Hash` is expected to enable MD5
71-
* Hashing computations.
76+
* hashes.
7277
*/
7378
inline DisableMD5Hash EnableMD5Hash() { return DisableMD5Hash(false); }
7479

7580
/**
76-
* Provide a pre-computed MD5 hash value to an upload or download request.
81+
* Provide a pre-computed CRC32C checksum value.
82+
*
83+
* The application may be able to obtain a CRC32C checksum in some out-of-band
84+
* way. For example, if the object was downloaded from some other cloud storage
85+
* service, or because the application already queried the GCS object metadata.
86+
* In these cases, providing the value to the client library improves the
87+
* end-to-end data integrity verification.
7788
*
78-
* The application may know what the MD5 hash value of a particular object is,
79-
* for example, because it was downloaded from GCS or some other cloud storage
80-
* service. In these cases, the client can include the hash value in the
81-
* request for better end-to-end validation.
89+
* @see
90+
* https://sigops.org/s/conferences/hotos/2021/papers/hotos21-s01-hochschild.pdf
8291
*/
8392
struct Crc32cChecksumValue
8493
: public internal::ComplexOption<Crc32cChecksumValue, std::string> {
@@ -90,20 +99,22 @@ struct Crc32cChecksumValue
9099
};
91100

92101
/**
93-
* Compute the MD5 Hash of a string in the format preferred by GCS.
102+
* Compute the CRC32C checksum of a string in the format preferred by GCS.
94103
*/
95104
std::string ComputeCrc32cChecksum(std::string const& payload);
96105

97106
/**
98-
* Disable MD5 Hashing computations.
107+
* Disable CRC32C checksum computations.
99108
*
100-
* By default the GCS client library computes MD5 hashes in all
101-
* `Client::InsertObject` calls. The application can disable the hash
102-
* computation by passing this parameter.
109+
* By default the GCS client library computes CRC32C checksums in all upload and
110+
* download operations. The application can use this option to disable the
111+
* checksum computation.
103112
*
104-
* @warning Disabling MD5 hashing exposes your application to data corruption.
105-
* We recommend that all uploads to GCS are protected by the supported
106-
* checksums and/or hashes.
113+
* @warning MD5 hashes are disabled by default, as they are computationally
114+
* expensive, and CRC32C checksums provide enough data integrity protection
115+
* for most applications. Disabling CRC32C checksums while MD5 hashes remain
116+
* disabled exposes your application to data corruption. We recommend that all
117+
* uploads to GCS and downloads from GCS use CRC32C checksums.
107118
*/
108119
struct DisableCrc32cChecksum
109120
: public internal::ComplexOption<DisableCrc32cChecksum, bool> {

0 commit comments

Comments
 (0)