@@ -113,8 +113,8 @@ func (f archiveFooter) metadataSpan() byteSpan {
113113 return byteSpan {offset : f .fileSize - f .actualFooterSize () - uint64 (f .metadataSize ), length : uint64 (f .metadataSize )}
114114}
115115
116- func newArchiveMetadata (ctx context.Context , reader tableReaderAt , fileSize uint64 , stats * Stats ) (* ArchiveMetadata , error ) {
117- aRdr , err := newArchiveReader (ctx , reader , fileSize , stats )
116+ func newArchiveMetadata (ctx context.Context , reader tableReaderAt , name hash. Hash , fileSize uint64 , stats * Stats ) (* ArchiveMetadata , error ) {
117+ aRdr , err := newArchiveReader (ctx , reader , name , fileSize , stats )
118118 if err != nil {
119119 return nil , err
120120 }
@@ -180,21 +180,21 @@ func newArchiveMetadata(ctx context.Context, reader tableReaderAt, fileSize uint
180180 }, nil
181181}
182182
183- func newArchiveReaderFromFooter (ctx context.Context , reader tableReaderAt , fileSz uint64 , footer []byte , stats * Stats ) (archiveReader , error ) {
183+ func newArchiveReaderFromFooter (ctx context.Context , reader tableReaderAt , name hash. Hash , fileSz uint64 , footer []byte , stats * Stats ) (archiveReader , error ) {
184184 if uint64 (len (footer )) != archiveFooterSize {
185185 return archiveReader {}, errors .New ("runtime error: invalid footer." )
186186 }
187187
188- ftr , err := buildFooter (fileSz , footer )
188+ ftr , err := buildFooter (name , fileSz , footer )
189189 if err != nil {
190190 return archiveReader {}, err
191191 }
192192
193193 return buildArchiveReader (ctx , reader , ftr , stats )
194194}
195195
196- func newArchiveReader (ctx context.Context , reader tableReaderAt , fileSize uint64 , stats * Stats ) (archiveReader , error ) {
197- footer , err := loadFooter (ctx , reader , fileSize , stats )
196+ func newArchiveReader (ctx context.Context , reader tableReaderAt , name hash. Hash , fileSize uint64 , stats * Stats ) (archiveReader , error ) {
197+ footer , err := loadFooter (ctx , reader , name , fileSize , stats )
198198 if err != nil {
199199 return archiveReader {}, fmt .Errorf ("Failed to loadFooter: %w" , err )
200200 }
@@ -355,17 +355,17 @@ func newSectionReader(ctx context.Context, rd ReaderAtWithStats, off, len int64,
355355 return io .NewSectionReader (readerAtWithStatsBridge {rd , ctx , stats }, off , len )
356356}
357357
358- func loadFooter (ctx context.Context , reader ReaderAtWithStats , fileSize uint64 , stats * Stats ) (f archiveFooter , err error ) {
358+ func loadFooter (ctx context.Context , reader ReaderAtWithStats , name hash. Hash , fileSize uint64 , stats * Stats ) (f archiveFooter , err error ) {
359359 section := newSectionReader (ctx , reader , int64 (fileSize - archiveFooterSize ), int64 (archiveFooterSize ), stats )
360360 buf := make ([]byte , archiveFooterSize )
361361 _ , err = io .ReadFull (section , buf )
362362 if err != nil {
363363 return
364364 }
365- return buildFooter (fileSize , buf )
365+ return buildFooter (name , fileSize , buf )
366366}
367367
368- func buildFooter (fileSize uint64 , buf []byte ) (f archiveFooter , err error ) {
368+ func buildFooter (name hash. Hash , fileSize uint64 , buf []byte ) (f archiveFooter , err error ) {
369369 f .formatVersion = buf [afrVersionOffset ]
370370 f .fileSignature = string (buf [afrSigOffset :])
371371 // Verify File Signature
@@ -404,14 +404,7 @@ func buildFooter(fileSize uint64, buf []byte) (f archiveFooter, err error) {
404404 f .metaCheckSum = sha512Sum (buf [afrMetaChkSumOffset : afrMetaChkSumOffset + sha512 .Size ])
405405 f .fileSize = fileSize
406406
407- // calculate the hash of the footer. We don't currently verify that this is what was used to load the content.
408- sha := sha512 .New ()
409- if smallFooter {
410- buf = buf [4 :]
411- }
412-
413- sha .Write (buf )
414- f .hash = hash .New (sha .Sum (nil )[:hash .ByteLen ])
407+ f .hash = name
415408
416409 return
417410}
@@ -583,22 +576,6 @@ func (ar archiveReader) getMetadata(ctx context.Context, stats *Stats) ([]byte,
583576 return ar .readByteSpan (ctx , ar .footer .metadataSpan (), stats )
584577}
585578
586- // verifyDataCheckSum verifies the checksum of the data section of the archive. Note - this requires a fully read of
587- // the data section, which could be sizable.
588- func (ar archiveReader ) verifyDataCheckSum (ctx context.Context , stats * Stats ) error {
589- return verifyCheckSum (ctx , ar .reader , ar .footer .dataSpan (), ar .footer .dataCheckSum , stats )
590- }
591-
592- // verifyIndexCheckSum verifies the checksum of the index section of the archive.
593- func (ar archiveReader ) verifyIndexCheckSum (ctx context.Context , stats * Stats ) error {
594- return verifyCheckSum (ctx , ar .reader , ar .footer .totalIndexSpan (), ar .footer .indexCheckSum , stats )
595- }
596-
597- // verifyMetaCheckSum verifies the checksum of the metadata section of the archive.
598- func (ar archiveReader ) verifyMetaCheckSum (ctx context.Context , stats * Stats ) error {
599- return verifyCheckSum (ctx , ar .reader , ar .footer .metadataSpan (), ar .footer .metaCheckSum , stats )
600- }
601-
602579func (ar archiveReader ) iterate (ctx context.Context , cb func (chunks.Chunk ) error , stats * Stats ) error {
603580 for i := uint32 (0 ); i < ar .footer .chunkCount ; i ++ {
604581 var hasBytes [hash .ByteLen ]byte
0 commit comments