1#ifndef SOURCEMETA_CORE_JOSE_JWE_H_
2#define SOURCEMETA_CORE_JOSE_JWE_H_
4#ifndef SOURCEMETA_CORE_JOSE_EXPORT
5#include <sourcemeta/core/jose_export.h>
9#include <sourcemeta/core/jose_algorithm.h>
10#include <sourcemeta/core/jose_error.h>
13#include <sourcemeta/core/json.h>
19namespace sourcemeta::core {
34class SOURCEMETA_CORE_JOSE_EXPORT
JWE {
38 explicit JWE(
const std::string_view input);
42 [[nodiscard]]
static auto from(
const std::string_view input)
43 -> std::optional<JWE>;
50 return this->algorithm_;
57 return this->encryption_;
61 [[nodiscard]]
auto key_id() const noexcept -> std::optional<std::string_view>;
64 [[nodiscard]] auto
header() const noexcept -> const
JSON & {
73 return this->protected_header_;
79 return this->encrypted_key_;
85 return this->initialization_vector_;
89 [[nodiscard]]
auto ciphertext() const noexcept -> std::string_view {
90 return this->ciphertext_;
94 [[nodiscard]]
auto tag() const noexcept -> std::string_view {
100 static auto parse(
const std::string_view input,
JWE &result) -> bool;
103#pragma warning(disable : 4251)
105 std::string protected_header_;
106 std::string encrypted_key_;
107 std::string initialization_vector_;
108 std::string ciphertext_;
110 JSON header_{
nullptr};
111 std::optional<JWEAlgorithm> algorithm_;
112 std::optional<JWEEncryption> encryption_;
114#pragma warning(default : 4251)
auto encrypted_key() const noexcept -> std::string_view
Definition jose_jwe.h:78
auto header() const noexcept -> const JSON &
The decoded protected header.
Definition jose_jwe.h:64
auto initialization_vector() const noexcept -> std::string_view
The decoded JWE Initialization Vector.
Definition jose_jwe.h:83
auto tag() const noexcept -> std::string_view
The decoded JWE Authentication Tag.
Definition jose_jwe.h:94
auto encryption() const noexcept -> std::optional< JWEEncryption >
Definition jose_jwe.h:55
auto ciphertext() const noexcept -> std::string_view
The decoded JWE Ciphertext.
Definition jose_jwe.h:89
auto key_id() const noexcept -> std::optional< std::string_view >
The key identifier from the protected header, if present.
static auto from(const std::string_view input) -> std::optional< JWE >
JWE(const std::string_view input)
auto protected_header() const noexcept -> std::string_view
Definition jose_jwe.h:72
auto algorithm() const noexcept -> std::optional< JWEAlgorithm >
Definition jose_jwe.h:49
JWEAlgorithm
Definition jose_algorithm.h:125
JWEEncryption
Definition jose_algorithm.h:152