blob: f2e8566353c678b276414589eccd81a4d2767e6f [file]
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef THIRD_PARTY_CREDENTIO_FORMATS_TIFF_HASHER_H_
#define THIRD_PARTY_CREDENTIO_FORMATS_TIFF_HASHER_H_
#include <cstdint>
#include "absl/status/status.h"
#include "bindings/input_hasher.h"
#include "riegeli/bytes/reader.h"
#include "riegeli/bytes/writer.h"
namespace credentio {
// Reads the given length from the reader and hashes the bytes. Returns an error
// if the read fails.
absl::Status ReadHash(riegeli::Reader& reader, int64_t length,
InputHasher& hasher);
// Copies the given length from the reader to the writer, hashing the bytes as
// they are copied. This is a helper function for reading a chunk of data and
// hashing it, then writing it to the destination. Returns an error if the read
// or write fails.
absl::Status ReadHashWrite(riegeli::Reader& reader, int64_t length,
InputHasher& hasher, riegeli::Writer& writer);
// Writes the given value to the writer, hashing the bytes as they are written.
// This is a helper function for writing a chunk of data and hashing it, then
// writing it to the destination. Returns an error if the write fails.
absl::Status HashWrite16(uint16_t value, bool is_big_endian,
InputHasher& hasher, riegeli::Writer& writer);
absl::Status HashWrite32(uint32_t value, bool is_big_endian,
InputHasher& hasher, riegeli::Writer& writer);
// Writes the given value to the writer. Returns an error if the write fails.
absl::Status Write32(uint32_t value, bool is_big_endian,
riegeli::Writer& writer);
} // namespace credentio
#endif // THIRD_PARTY_CREDENTIO_FORMATS_TIFF_HASHER_H_