| // 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_TSP_PARSED_TIMESTAMP_TOKEN_H_ |
| #define THIRD_PARTY_CREDENTIO_TSP_PARSED_TIMESTAMP_TOKEN_H_ |
| |
| #include <string> |
| #include <vector> |
| |
| #include "absl/base/attributes.h" |
| #include "absl/status/status.h" |
| #include "absl/status/statusor.h" |
| #include "absl/strings/string_view.h" |
| #include "crypto/algorithms.h" |
| |
| namespace credentio { |
| |
| // Represents a successfully parsed CMS TimestampToken ready for extraction. |
| class ParsedTimestampToken { |
| public: |
| virtual ~ParsedTimestampToken() = default; |
| |
| // Verifies the signature of this token. Note that this does not perform trust |
| // checks. |
| virtual absl::Status VerifySignature() const = 0; |
| |
| // Returns the hash algorithm used to calculate the message imprint. |
| virtual absl::StatusOr<HashAlgorithm> GetMessageImprintHashAlgorithm() |
| const = 0; |
| |
| // Returns the certificate chain of the TSA certificate. The first element |
| // is the leaf certificate, followed by any intermediate certificates. |
| // The certificates are DER encoded. |
| virtual absl::StatusOr<std::vector<std::string>> GetCertificateChain() |
| const = 0; |
| |
| // Extracts the DER-encoded SigningCertificateV2 attribute from the signer. |
| // The lifetime of the returned absl::string_view is tied to this |
| // ParsedTimestampToken instance. |
| virtual absl::StatusOr<absl::string_view> GetSigningCertificateV2Bytes() const |
| ABSL_ATTRIBUTE_LIFETIME_BOUND = 0; |
| |
| // Gets the raw DER-encoded TstInfo content. |
| // The lifetime of the returned absl::string_view is tied to this |
| // ParsedTimestampToken instance. |
| virtual absl::StatusOr<absl::string_view> GetTstInfoBytes() const |
| ABSL_ATTRIBUTE_LIFETIME_BOUND = 0; |
| }; |
| |
| } // namespace credentio |
| |
| #endif // THIRD_PARTY_CREDENTIO_TSP_PARSED_TIMESTAMP_TOKEN_H_ |