blob: 98c944a96b8cae45a7729c57a3db698e9ed7a0e5 [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_TESTING_CMS_H_
#define THIRD_PARTY_CREDENTIO_TESTING_CMS_H_
#include <cstdint>
#include <string>
#include <vector>
#include "absl/functional/function_ref.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
#include "openssl/base.h"
namespace credentio_testing {
struct SignedCmsOptions {
absl::Time signing_time = absl::UnixEpoch();
bool include_user_certificate = false;
absl::Span<const X509* const> ca_certificates = {};
absl::string_view extra_signed_attributes = "";
bool is_time_stamp_token = false;
};
// Creates a minimal signed CMS structure (SignedData) wrapping the given
// contents. This is a simplified implementation intended for testing and
// internal use.
absl::StatusOr<std::string> CreateSignedCms(
absl::Span<const absl::string_view> contents,
const X509& signer_certificate,
absl::FunctionRef<absl::StatusOr<std::vector<uint8_t>>(absl::string_view)>
sign_callback,
const SignedCmsOptions& options = {});
} // namespace credentio_testing
#endif // THIRD_PARTY_CREDENTIO_TESTING_CMS_H_