| // 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_JUMBF_TEST_UTILS_H_ |
| #define THIRD_PARTY_CREDENTIO_JUMBF_TEST_UTILS_H_ |
| |
| #include <stdbool.h> |
| |
| #include <cstdint> |
| #include <optional> |
| #include <string> |
| |
| #include "absl/strings/cord.h" |
| #include "absl/strings/string_view.h" |
| #include "absl/types/span.h" |
| #include "uuid/uuid.h" |
| |
| namespace jumbf { |
| |
| // Wraps `content` in the basic box structure (section 4.3) |
| std::string WrapBox(absl::string_view content, uint32_t tbox); |
| |
| // Wraps `content` in the basic box structure, using an LBox value of 0 |
| // (section 4.3) |
| std::string WrapUndeterminedLengthBox(absl::string_view content, uint32_t tbox); |
| |
| // Serializes a 16 byte UUID in RFC 4122 (ISO / IEC 11578) format and advances |
| // `dest`. |
| void SerializeUuid(char** dest, credentio::Uuid uuid); |
| |
| // Serializes a description box (section A.3) with the given UUID and label. |
| std::string EncodeDescriptionBox(credentio::Uuid uuid, |
| std::optional<absl::string_view> label, |
| bool requestable = false); |
| |
| // Serializes a CBOR box (section B.7) with the given contents. |
| std::string EncodeCborBox(absl::string_view contents); |
| |
| // Serializes a superbox (section A.2) with the given UUID, label, and |
| // contents. |
| std::string EncodeSuperBox(credentio::Uuid uuid, |
| std::optional<absl::string_view> label, |
| absl::Span<const absl::string_view> contents, |
| bool requestable = false); |
| |
| // This is only safe if the array backing `data` is a compile-time constant. |
| absl::Cord CordFromConstexpr(absl::string_view data); |
| |
| } // namespace jumbf |
| |
| #endif // THIRD_PARTY_CREDENTIO_JUMBF_TEST_UTILS_H_ |