@@ -41,7 +41,7 @@ namespace NKikimr::NPDisk {
41
41
// obtain the header and decrypt its encrypted part, then validate the hash
42
42
TMetadataHeader *header = reinterpret_cast <TMetadataHeader*>(GetBuffer ());
43
43
header->Encrypt (cypher);
44
- if (header->CheckHash ()) {
44
+ if (header->CheckHash ((ui64*)( void *)&PDisk-> Format . ChunkKey )) {
45
45
// check we have read it all
46
46
const ui32 total = sizeof (TMetadataHeader) + header->Length ;
47
47
if (total <= Buffer.size ()) {
@@ -167,7 +167,7 @@ namespace NKikimr::NPDisk {
167
167
168
168
auto *header = reinterpret_cast <TMetadataHeader*>(Buffer.GetDataMut ());
169
169
header->Encrypt (cypher);
170
- if (!header->CheckHash ()) {
170
+ if (!header->CheckHash ((ui64*)( void *)&Format. DataKey )) {
171
171
req->ErrorReason = " header has is not valid" ;
172
172
} else if (header->TotalRecords != 1 || header->RecordIndex != 0 || header->SequenceNumber != 0 ) {
173
173
req->ErrorReason = " header fields are filled incorrectly" ;
@@ -593,7 +593,7 @@ namespace NKikimr::NPDisk {
593
593
594
594
const size_t payloadSize = Min<size_t >(slotSize, metadataSize - offset);
595
595
TRcBuf payload = CreateMetadataPayload (write.Metadata , offset, payloadSize, Format.SectorSize ,
596
- Cfg->EnableSectorEncryption , Format.ChunkKey , Meta.NextSequenceNumber , i, numSlotsRequired);
596
+ Cfg->EnableSectorEncryption , Format.ChunkKey , Meta.NextSequenceNumber , i, numSlotsRequired, (ui64*)( void *)&Format. ChunkKey );
597
597
598
598
completion->AddQuery (key, std::move (payload));
599
599
completion->CostNs += DriveModel.TimeForSizeNs (payload.size (), key.ChunkIdx , TDriveModel::OP_TYPE_WRITE);
@@ -617,7 +617,7 @@ namespace NKikimr::NPDisk {
617
617
}
618
618
619
619
TRcBuf payload = CreateMetadataPayload (write.Metadata , 0 , write.Metadata .size (), DefaultSectorSize,
620
- true , fmt.DataKey , 0 , 0 , 1 );
620
+ true , fmt.DataKey , 0 , 0 , 1 , (ui64*)( void *)&fmt. DataKey );
621
621
const size_t bytesToWrite = payload.size ();
622
622
623
623
ui64 rawDeviceSize = 0 ;
@@ -718,7 +718,7 @@ namespace NKikimr::NPDisk {
718
718
}
719
719
720
720
TRcBuf TPDisk::CreateMetadataPayload (TRcBuf& metadata, size_t offset, size_t payloadSize, ui32 sectorSize,
721
- bool encryption, const TKey& key, ui64 sequenceNumber, ui32 recordIndex, ui32 totalRecords) {
721
+ bool encryption, const TKey& key, ui64 sequenceNumber, ui32 recordIndex, ui32 totalRecords, const ui64 *magic ) {
722
722
Y_ABORT_UNLESS (offset + payloadSize <= metadata.size ());
723
723
724
724
Y_DEBUG_ABORT_UNLESS (IsPowerOf2 (sectorSize));
@@ -749,7 +749,7 @@ namespace NKikimr::NPDisk {
749
749
.DataHash = dataHasher.GetHashResult (),
750
750
};
751
751
752
- header->SetHash ();
752
+ header->SetHash (magic );
753
753
header->EncryptData (cypher);
754
754
header->Encrypt (cypher);
755
755
@@ -791,7 +791,7 @@ namespace NKikimr::NPDisk {
791
791
const NMeta::TSlotKey key = freeSlotKeys[i];
792
792
const size_t payloadSize = Min<size_t >(slotSize, metadataSize - offset);
793
793
TRcBuf payload = CreateMetadataPayload (metadata, offset, payloadSize, format.SectorSize ,
794
- Cfg->EnableSectorEncryption , format.ChunkKey , 1 , i, numSlotsRequired);
794
+ Cfg->EnableSectorEncryption , format.ChunkKey , 1 , i, numSlotsRequired, (ui64*)( void *)&format. ChunkKey );
795
795
BlockDevice->PwriteSync (payload.data (), payload.size (), format.Offset (key.ChunkIdx , key.OffsetInSectors ), {}, nullptr );
796
796
}
797
797
0 commit comments