| // 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_UPDATER_H_ | |
| #define THIRD_PARTY_CREDENTIO_COSE_TIMESTAMP_UPDATER_H_ | |
| #include <string> | |
| #include "absl/base/nullability.h" | |
| #include "absl/functional/any_invocable.h" | |
| #include "absl/log/die_if_null.h" | |
| #include "absl/status/status.h" | |
| #include "async/async_context.h" | |
| #include "cose/timestamp_creator.h" | |
| namespace credentio { | |
| // Updates the timestamp in a COSE C2PA claim signature. | |
| class TimestampUpdater { | |
| public: | |
| explicit TimestampUpdater( | |
| const TimestampCreator* absl_nonnull timestamp_creator) | |
| : timestamp_creator_(*ABSL_DIE_IF_NULL(timestamp_creator)) {} | |
| // Creates a timestamp, and if successful, updates the timestamp in the | |
| // provided serialized COSE_Sign1_Tagged structure. It guarantees that the | |
| // size of the serialized structure does not change. | |
| void UpdateTimestamp(std::string* absl_nonnull encoded_cose_sign1, | |
| AsyncContext async_context, | |
| absl::AnyInvocable<void(absl::Status) &&> cb) const; | |
| private: | |
| const TimestampCreator& timestamp_creator_; | |
| }; | |
| } // namespace credentio | |
| #endif // THIRD_PARTY_CREDENTIO_COSE_TIMESTAMP_UPDATER_H_ |