| // 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_READ_HANDLER_H_ |
| #define THIRD_PARTY_CREDENTIO_CRYPTO_TIMESTAMP_READ_HANDLER_H_ |
| |
| #include "absl/status/statusor.h" |
| #include "absl/strings/string_view.h" |
| #include "tsp/verified_timestamp.h" |
| |
| namespace credentio { |
| |
| // A consumer of RFC3161 TimeStampTokens. |
| class TimestampReadHandler { |
| public: |
| // Validates an RFC 3161 TimeStampToken. Checks CMS signature and certificate |
| // trustworthiness. Caller must verify that the message imprint of the |
| // returned `VerifiedTimestamp` matches the signature to which the timestamp |
| // applies. |
| // |
| // Returns: |
| // - UNAUTHENTICATED if the TSA's certificate cannot be trusted or if the |
| // timestamp's signature is invalid. |
| // - INVALID_ARGUMENT if `cms` cannot be parsed. |
| // - OUT_OF_RANGE if the TSA's certificate was not within its validity |
| // period at the asserted time. |
| // - UNAVAILABLE if the root trust list cannot be accessed (only possible on |
| // platforms where it is not stored in-process.) |
| virtual absl::StatusOr<VerifiedTimestamp> VerifyTimestamp( |
| absl::string_view cms) const = 0; |
| virtual ~TimestampReadHandler() = default; |
| }; |
| |
| } // namespace credentio |
| |
| #endif // THIRD_PARTY_CREDENTIO_CRYPTO_TIMESTAMP_READ_HANDLER_H_ |