From ebbb935a5f4e9cc023842461bd4038028e8e3dc9 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Tue, 7 Jul 2026 14:31:57 +0200 Subject: [PATCH] Remove the UNSET key type The UNSET key type is not part of the protocol so there is no reason to have it. While at it also remove the constructor for an "empty" key object. That is not something we are using either, and a key without value or type does not make much sense to support. --- kmipclient/src/Key.cpp | 1 - kmipcore/include/kmipcore/key.hpp | 13 ++----------- kmipcore/src/kmip_requests.cpp | 2 -- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/kmipclient/src/Key.cpp b/kmipclient/src/Key.cpp index c84bc31..a67bf47 100644 --- a/kmipclient/src/Key.cpp +++ b/kmipclient/src/Key.cpp @@ -36,7 +36,6 @@ namespace kmipclient { return std::make_unique( core_key.value(), core_key.attributes() ); - case KeyType::UNSET: default: throw kmipcore::KmipException( "Unsupported key type in core->client conversion" diff --git a/kmipcore/include/kmipcore/key.hpp b/kmipcore/include/kmipcore/key.hpp index 285488b..6045570 100644 --- a/kmipcore/include/kmipcore/key.hpp +++ b/kmipcore/include/kmipcore/key.hpp @@ -14,13 +14,7 @@ namespace kmipcore { /** @brief Key object families represented by @ref Key. */ - enum class KeyType { - UNSET, - SYMMETRIC_KEY, - PUBLIC_KEY, - PRIVATE_KEY, - CERTIFICATE - }; + enum class KeyType { SYMMETRIC_KEY, PUBLIC_KEY, PRIVATE_KEY, CERTIFICATE }; /** * Minimal crypto key representation as KMIP spec sees it. @@ -46,9 +40,6 @@ namespace kmipcore { ) : ManagedObject(value, std::move(attrs)), key_type(k_type) {} - /** @brief Constructs an empty key object. */ - Key() = default; - Key(const Key &) = default; Key &operator=(const Key &) = default; Key(Key &&) noexcept = default; @@ -61,7 +52,7 @@ namespace kmipcore { [[nodiscard]] size_t size() const noexcept { return value_.size(); } private: - KeyType key_type = KeyType::UNSET; + KeyType key_type; }; } // namespace kmipcore diff --git a/kmipcore/src/kmip_requests.cpp b/kmipcore/src/kmip_requests.cpp index b60c380..9f5fbd7 100644 --- a/kmipcore/src/kmip_requests.cpp +++ b/kmipcore/src/kmip_requests.cpp @@ -233,7 +233,6 @@ namespace kmipcore { KMIP_NOT_IMPLEMENTED, "Certificate registration is not yet supported" ); - case KeyType::UNSET: default: throw KmipException( KMIP_INVALID_FIELD, "Unsupported key type for Register" @@ -250,7 +249,6 @@ namespace kmipcore { return KMIP_OBJTYPE_PUBLIC_KEY; case KeyType::CERTIFICATE: return KMIP_OBJTYPE_CERTIFICATE; - case KeyType::UNSET: default: throw KmipException( KMIP_INVALID_FIELD, "Unsupported key type for Register"