blob: 817ad2345799d800a4689d947934a913c83009e3 [file] [edit]
// 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_COSE_TIMESTAMP_CREATOR_H_
#define THIRD_PARTY_CREDENTIO_COSE_TIMESTAMP_CREATOR_H_
#include <optional>
#include <string>
#include "absl/base/nullability.h"
#include "absl/functional/any_invocable.h"
#include "absl/log/die_if_null.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "async/async_context.h"
#include "cose/sig_structure.h"
#include "crypto/hash.h"
#include "crypto/timestamp_write_handler.h"
namespace credentio {
// Creator of timestamps for COSE C2PA claim signatures.
class TimestampCreator {
public:
struct Options {
AsyncContext async_context = AsyncContext();
};
explicit TimestampCreator(
const TimestampWriteHandler* absl_nonnull timestamp_creator,
const HasherFactory* absl_nonnull hasher_factory)
: timestamp_handler_(*ABSL_DIE_IF_NULL(timestamp_creator)),
hasher_factory_(*ABSL_DIE_IF_NULL(hasher_factory)) {}
// Creates a TimeStampToken that countersigns the given
// CoseSign1TaggedStructure.
void CreateTimestamp(
const CoseSign1TaggedStructure& cose_sign1, Options options,
absl::AnyInvocable<void(absl::StatusOr<std::string>) &&> cb) const;
private:
const TimestampWriteHandler& timestamp_handler_;
const HasherFactory& hasher_factory_;
};
} // namespace credentio
#endif // THIRD_PARTY_CREDENTIO_COSE_TIMESTAMP_CREATOR_H_