@@ -15,6 +15,7 @@ import (
15
15
"fmt"
16
16
"hash"
17
17
"hash/crc32"
18
+ "hash/crc64"
18
19
"io"
19
20
"log"
20
21
"reflect"
@@ -29,6 +30,8 @@ import (
29
30
"github.com/aws/smithy-go/middleware"
30
31
)
31
32
33
+ const crc64NVME = 0x9a6c_9329_ac4b_c9b5
34
+
32
35
var integBuf12MB = make ([]byte , 1024 * 1024 * 12 )
33
36
var integMD512MB = fmt .Sprintf ("%x" , md5 .Sum (integBuf12MB ))
34
37
@@ -124,6 +127,7 @@ func TestInteg_UploadPresetChecksum(t *testing.T) {
124
127
singlePartBytes := integBuf12MB [0 :manager .DefaultUploadPartSize ]
125
128
singlePartCRC32 := base64Sum (crc32 .NewIEEE (), singlePartBytes )
126
129
singlePartCRC32C := base64Sum (crc32 .New (crc32 .MakeTable (crc32 .Castagnoli )), singlePartBytes )
130
+ singlePartCRC64NVME := base64Sum (crc64 .New (crc64 .MakeTable (crc64NVME )), singlePartBytes )
127
131
singlePartSHA1 := base64Sum (sha1 .New (), singlePartBytes )
128
132
singlePartSHA256 := base64Sum (sha256 .New (), singlePartBytes )
129
133
singlePartMD5 := base64Sum (md5 .New (), singlePartBytes )
@@ -132,6 +136,7 @@ func TestInteg_UploadPresetChecksum(t *testing.T) {
132
136
multiPartTailBytes := integBuf12MB [manager .DefaultUploadPartSize * 2 :]
133
137
multiPartTailCRC32 := base64Sum (crc32 .NewIEEE (), multiPartTailBytes )
134
138
multiPartTailCRC32C := base64Sum (crc32 .New (crc32 .MakeTable (crc32 .Castagnoli )), multiPartTailBytes )
139
+ multiPartTailCRC64NVME := base64Sum (crc64 .New (crc64 .MakeTable (crc64NVME )), multiPartTailBytes )
135
140
multiPartTailSHA1 := base64Sum (sha1 .New (), multiPartTailBytes )
136
141
multiPartTailSHA256 := base64Sum (sha256 .New (), multiPartTailBytes )
137
142
multiPartTailETag := fmt .Sprintf ("%q" , hexSum (md5 .New (), multiPartTailBytes ))
@@ -143,20 +148,25 @@ func TestInteg_UploadPresetChecksum(t *testing.T) {
143
148
multiPartSHA256 := base64SumOfSums (sha256 .New (), []string {singlePartSHA256 , singlePartSHA256 , multiPartTailSHA256 })
144
149
multiPartETag := `"4e982d58b6c2ce178ae042c23f9bca6e-3"` // Not obvious how this is computed
145
150
151
+ // s3 wants running checksum for crc64nvme
152
+ multiPartCRC64NVME := base64Sum (crc64 .New (crc64 .MakeTable (crc64NVME )), integBuf12MB )
153
+
146
154
cases := map [string ]map [string ]struct {
147
- algorithm s3types.ChecksumAlgorithm
148
- payload io.Reader
149
- checksumCRC32 string
150
- checksumCRC32C string
151
- checksumSHA1 string
152
- checksumSHA256 string
153
- contentMD5 string
154
- expectParts []s3types.CompletedPart
155
- expectChecksumCRC32 string
156
- expectChecksumCRC32C string
157
- expectChecksumSHA1 string
158
- expectChecksumSHA256 string
159
- expectETag string
155
+ algorithm s3types.ChecksumAlgorithm
156
+ payload io.Reader
157
+ checksumCRC32 string
158
+ checksumCRC32C string
159
+ checksumCRC64NVME string
160
+ checksumSHA1 string
161
+ checksumSHA256 string
162
+ contentMD5 string
163
+ expectParts []s3types.CompletedPart
164
+ expectChecksumCRC32 string
165
+ expectChecksumCRC32C string
166
+ expectChecksumCRC64NVME string
167
+ expectChecksumSHA1 string
168
+ expectChecksumSHA256 string
169
+ expectETag string
160
170
}{
161
171
"auto single part" : {
162
172
"no checksum algorithm passed" : {
@@ -176,6 +186,12 @@ func TestInteg_UploadPresetChecksum(t *testing.T) {
176
186
expectChecksumCRC32C : singlePartCRC32C ,
177
187
expectETag : singlePartETag ,
178
188
},
189
+ "CRC64NVME" : {
190
+ algorithm : s3types .ChecksumAlgorithmCrc64nvme ,
191
+ payload : bytes .NewReader (singlePartBytes ),
192
+ expectChecksumCRC64NVME : singlePartCRC64NVME ,
193
+ expectETag : singlePartETag ,
194
+ },
179
195
"SHA1" : {
180
196
algorithm : s3types .ChecksumAlgorithmSha1 ,
181
197
payload : bytes .NewReader (singlePartBytes ),
@@ -202,6 +218,12 @@ func TestInteg_UploadPresetChecksum(t *testing.T) {
202
218
expectChecksumCRC32C : singlePartCRC32C ,
203
219
expectETag : singlePartETag ,
204
220
},
221
+ "CRC64NVME" : {
222
+ payload : bytes .NewReader (singlePartBytes ),
223
+ checksumCRC64NVME : singlePartCRC64NVME ,
224
+ expectChecksumCRC64NVME : singlePartCRC64NVME ,
225
+ expectETag : singlePartETag ,
226
+ },
205
227
"SHA1" : {
206
228
payload : bytes .NewReader (singlePartBytes ),
207
229
checksumSHA1 : singlePartSHA1 ,
@@ -290,6 +312,29 @@ func TestInteg_UploadPresetChecksum(t *testing.T) {
290
312
expectChecksumCRC32C : multiPartCRC32C ,
291
313
expectETag : multiPartETag ,
292
314
},
315
+ "CRC64NVME" : {
316
+ algorithm : s3types .ChecksumAlgorithmCrc64nvme ,
317
+ payload : bytes .NewReader (multiPartBytes ),
318
+ expectParts : []s3types.CompletedPart {
319
+ {
320
+ ChecksumCRC64NVME : aws .String (singlePartCRC64NVME ),
321
+ ETag : aws .String (singlePartETag ),
322
+ PartNumber : aws .Int32 (1 ),
323
+ },
324
+ {
325
+ ChecksumCRC64NVME : aws .String (singlePartCRC64NVME ),
326
+ ETag : aws .String (singlePartETag ),
327
+ PartNumber : aws .Int32 (2 ),
328
+ },
329
+ {
330
+ ChecksumCRC64NVME : aws .String (multiPartTailCRC64NVME ),
331
+ ETag : aws .String (multiPartTailETag ),
332
+ PartNumber : aws .Int32 (3 ),
333
+ },
334
+ },
335
+ expectChecksumCRC64NVME : multiPartCRC64NVME ,
336
+ expectETag : multiPartETag ,
337
+ },
293
338
"SHA1" : {
294
339
algorithm : s3types .ChecksumAlgorithmSha1 ,
295
340
payload : bytes .NewReader (multiPartBytes ),
@@ -386,6 +431,30 @@ func TestInteg_UploadPresetChecksum(t *testing.T) {
386
431
expectChecksumCRC32C : multiPartCRC32C ,
387
432
expectETag : multiPartETag ,
388
433
},
434
+ "CRC64NVME" : {
435
+ algorithm : s3types .ChecksumAlgorithmCrc64nvme ,
436
+ payload : bytes .NewReader (multiPartBytes ),
437
+ checksumCRC64NVME : multiPartCRC64NVME ,
438
+ expectParts : []s3types.CompletedPart {
439
+ {
440
+ ChecksumCRC64NVME : aws .String (singlePartCRC64NVME ),
441
+ ETag : aws .String (singlePartETag ),
442
+ PartNumber : aws .Int32 (1 ),
443
+ },
444
+ {
445
+ ChecksumCRC64NVME : aws .String (singlePartCRC64NVME ),
446
+ ETag : aws .String (singlePartETag ),
447
+ PartNumber : aws .Int32 (2 ),
448
+ },
449
+ {
450
+ ChecksumCRC64NVME : aws .String (multiPartTailCRC64NVME ),
451
+ ETag : aws .String (multiPartTailETag ),
452
+ PartNumber : aws .Int32 (3 ),
453
+ },
454
+ },
455
+ expectChecksumCRC64NVME : multiPartCRC64NVME ,
456
+ expectETag : multiPartETag ,
457
+ },
389
458
"SHA1" : {
390
459
algorithm : s3types .ChecksumAlgorithmSha1 ,
391
460
payload : bytes .NewReader (multiPartBytes ),
@@ -449,6 +518,7 @@ func TestInteg_UploadPresetChecksum(t *testing.T) {
449
518
ChecksumAlgorithm : c .algorithm ,
450
519
ChecksumCRC32 : toStringPtr (c .checksumCRC32 ),
451
520
ChecksumCRC32C : toStringPtr (c .checksumCRC32C ),
521
+ ChecksumCRC64NVME : toStringPtr (c .checksumCRC64NVME ),
452
522
ChecksumSHA1 : toStringPtr (c .checksumSHA1 ),
453
523
ChecksumSHA256 : toStringPtr (c .checksumSHA256 ),
454
524
ContentMD5 : toStringPtr (c .contentMD5 ),
@@ -467,6 +537,9 @@ func TestInteg_UploadPresetChecksum(t *testing.T) {
467
537
if e , a := c .expectChecksumCRC32C , aws .ToString (out .ChecksumCRC32C ); e != a {
468
538
t .Errorf ("expect %v CRC32C checksum, got %v" , e , a )
469
539
}
540
+ if e , a := c .expectChecksumCRC64NVME , aws .ToString (out .ChecksumCRC64NVME ); e != a {
541
+ t .Errorf ("expect %v CRC64NVME checksum, got %v" , e , a )
542
+ }
470
543
if e , a := c .expectChecksumSHA1 , aws .ToString (out .ChecksumSHA1 ); e != a {
471
544
t .Errorf ("expect %v SHA1 checksum, got %v" , e , a )
472
545
}
0 commit comments