blob: 8a6a7a7785fde7cfae608eff318330835375bf54 [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_CRYPTO_TIMESTAMP_WRITE_HANDLER_H_
#define THIRD_PARTY_CREDENTIO_CRYPTO_TIMESTAMP_WRITE_HANDLER_H_
#include <cstdint>
#include <optional>
#include <string>
#include "absl/functional/any_invocable.h"
#include "absl/status/statusor.h"
#include "async/async_context.h"
#include "crypto/algorithms.h"
namespace credentio {
// A producer of RFC3161 TimeStampTokens.
class TimestampWriteHandler {
public:
struct Options {
// If set, the async context to use for the timestamping request.
AsyncContext async_context = AsyncContext();
};
// Creates an RFC 3161 TimeStampToken.
//
// Returns:
// - UNAVAILABLE if timestamping is not available.
virtual void CreateTimestamp(
HashAlgorithm hash_algorithm, std::string hashed_message,
TimestampWriteHandler::Options options,
absl::AnyInvocable<void(absl::StatusOr<std::string>) &&> cb) const = 0;
// Returns an upper bound on the size of the serialized TimeStampTokens
// produced by this instance's CreateTimestamp. Implementations can use
// the helpers in timestamp_size.h.
virtual uint64_t max_timestamp_byte_size(
HashAlgorithm hash_algorithm) const = 0;
virtual ~TimestampWriteHandler() = default;
};
} // namespace credentio
#endif // THIRD_PARTY_CREDENTIO_CRYPTO_TIMESTAMP_WRITE_HANDLER_H_