1#ifndef SOURCEMETA_CORE_JOSE_JWK_PRIVATE_H_
2#define SOURCEMETA_CORE_JOSE_JWK_PRIVATE_H_
4#ifndef SOURCEMETA_CORE_JOSE_EXPORT
5#include <sourcemeta/core/jose_export.h>
8#include <sourcemeta/core/jose_algorithm.h>
10#include <sourcemeta/core/crypto.h>
11#include <sourcemeta/core/json.h>
18namespace sourcemeta::core {
38 enum class Type : std::uint8_t {
59 [[nodiscard]]
static auto from(
const JSON &value)
60 -> std::optional<JWKPrivate>;
64 [[nodiscard]]
static auto from(
JSON &&value) -> std::optional<JWKPrivate>;
69 [[nodiscard]]
static auto from_pem(
const std::string_view pem)
70 -> std::optional<JWKPrivate>;
90 [[nodiscard]]
auto type() const noexcept ->
Type {
return this->type_; }
93 [[nodiscard]]
auto key_id() const noexcept
94 -> std::optional<std::string_view> {
95 if (this->key_id_.has_value()) {
96 return std::string_view{*this->key_id_};
104 return this->algorithm_;
113 [[nodiscard]]
auto curve() const noexcept -> std::string_view {
122 return this->private_key_.has_value() ? &*this->private_key_ :
nullptr;
129 [[nodiscard]]
auto secret() const noexcept -> std::string_view {
130 return this->secret_;
141 [[nodiscard]] auto
thumbprint() const -> std::optional<std::
string>;
148#pragma warning(disable : 4251)
151 std::optional<std::string> key_id_;
152 std::optional<JWSAlgorithm> algorithm_;
154 std::optional<PrivateKey> private_key_;
156 std::string modulus_;
157 std::string exponent_;
158 std::string coordinate_x_;
159 std::string coordinate_y_;
160 std::string public_point_;
162#pragma warning(default : 4251)
EllipticCurve
Definition crypto_verify.h:28
JWKPrivate(JWKPrivate &&other) noexcept=default
A key exclusively owns its parsed private key, so it is move-only.
auto key_id() const noexcept -> std::optional< std::string_view >
The key identifier used to select this key, if present.
Definition jose_jwk_private.h:93
static auto from_pem(const std::string_view pem) -> std::optional< JWKPrivate >
static auto from(const JSON &value) -> std::optional< JWKPrivate >
static auto from_octets(const std::string_view secret) -> JWKPrivate
auto secret() const noexcept -> std::string_view
The raw symmetric secret, empty for asymmetric keys.
Definition jose_jwk_private.h:129
auto private_key() const noexcept -> const PrivateKey *
The parsed private key, or null when the material could not be decoded.
Definition jose_jwk_private.h:121
Type
The family of key material a key holds.
Definition jose_jwk_private.h:38
@ RSA
The RSA key type.
Definition jose_jwk_private.h:40
auto public_jwk() const -> std::optional< JSON >
auto type() const noexcept -> Type
The family of key material this key holds.
Definition jose_jwk_private.h:90
auto thumbprint() const -> std::optional< std::string >
auto algorithm() const noexcept -> std::optional< JWSAlgorithm >
The algorithm this key is intended for, if present.
Definition jose_jwk_private.h:103
auto curve() const noexcept -> std::string_view
The curve this key is pinned to, empty when it carries none.
Definition jose_jwk_private.h:113
static auto from(JSON &&value) -> std::optional< JWKPrivate >
JWSAlgorithm
Definition jose_algorithm.h:21