Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RSealedPage.cxx
Go to the documentation of this file.
1/// \file RSealedPage.cxx
2/// \author Jakob Blomer <jblomer@cern.ch>
3/// \date 2026-11-21
4
5/*************************************************************************
6 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#include <ROOT/RError.hxx>
15#include <ROOT/RSealedPage.hxx>
16
18{
19 if (!fHasChecksum)
20 return;
21
22 auto charBuf = reinterpret_cast<const unsigned char *>(fBuffer);
23 auto checksumBuf = const_cast<unsigned char *>(charBuf) + GetDataSize();
24 std::uint64_t xxhash3;
25 RNTupleSerializer::SerializeXxHash3(charBuf, GetDataSize(), xxhash3, checksumBuf);
26}
27
29{
30 if (!fHasChecksum)
32
33 auto success = RNTupleSerializer::VerifyXxHash3(reinterpret_cast<const unsigned char *>(fBuffer), GetDataSize());
34 if (!success)
35 return R__FAIL("page checksum verification failed, data corruption detected");
37}
38
40{
41 if (!fHasChecksum)
42 return R__FAIL("invalid attempt to extract non-existing page checksum");
43
44 assert(fBufferSize >= kNBytesPageChecksum);
45 std::uint64_t checksum;
47 reinterpret_cast<const unsigned char *>(fBuffer) + fBufferSize - kNBytesPageChecksum, checksum);
48 return checksum;
49}
fBuffer
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:322
static std::uint32_t SerializeXxHash3(const unsigned char *data, std::uint64_t length, std::uint64_t &xxhash3, void *buffer)
Writes a XxHash-3 64bit checksum of the byte range given by data and length.
static RResult< void > VerifyXxHash3(const unsigned char *data, std::uint64_t length, std::uint64_t &xxhash3)
Expects an xxhash3 checksum in the 8 bytes following data + length and verifies it.
static std::uint32_t DeserializeUInt64(const void *buffer, std::uint64_t &val)
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
Definition RError.hxx:222
bool fHasChecksum
If set, the last 8 bytes of the buffer are the xxhash of the rest of the buffer.
std::size_t GetDataSize() const
RResult< std::uint64_t > GetChecksum() const
Returns a failure if the sealed page has no checksum.
RResult< void > VerifyChecksumIfEnabled() const