Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keys update #6491

Merged
merged 29 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"sdk/core/azure-core-amqp/**/rust_amqp/azure_core_amqp/**/*",
"*.toml",
"sdk/storage/*/NOTICE.txt",
"sdk/tables/*/NOTICE.txt"
"sdk/tables/*/NOTICE.txt",
"sdk/keyvault/azure-security-keyvault-keys/src/generated/*",
],
// * Unless configured otherwise, these words are not case sensitive
// * Alphabetize the list when making changes so the list is easier for future
Expand Down
2 changes: 1 addition & 1 deletion sdk/keyvault/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/keyvault",
"Tag": "cpp/keyvault_682056eb2b"
"Tag": "cpp/keyvault_28cdcba8d8"
}
29 changes: 29 additions & 0 deletions sdk/keyvault/azure-security-keyvault-keys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ elseif(NOT AZ_ALL_LIBRARIES)
endif()
endif()

option(AZURE_TSP_KV_KEYS_GEN3 "Generate KeyVault Keys from TypeSpec" ON)
message("KeyVault Secrets TSP Generation ${AZURE_TSP_KV_KEYS_GEN}")

if(AZURE_TSP_KV_KEYS_GEN)
include(TSPCompile)
#typespec related repo information
set(TSP_SERVICE_PATH "Security.KeyVault.Keys")
set(TSP_DESTINATION "keyvault_keys")

#codegen related repo information
set(CODEGEN_SHA "83758baff29b89a8a7bd28fa26a692225f4f208f")
set(CODEGEN_DESTINATION "typespec-cpp")

#destination folders
set(GEN_FILES_DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}")
#generate code from typespec
GenerateCodeFromTypeSpec(${TSP_DESTINATION} ${TSP_SERVICE_PATH} ${CODEGEN_SHA} ${CODEGEN_DESTINATION} ${GEN_FILES_DESTINATION} OFF)
endif()
set(
AZURE_KEYVAULT_KEYS_HEADER
inc/azure/keyvault/keys.hpp
Expand Down Expand Up @@ -82,6 +100,8 @@ set(
src/json_web_key.cpp
src/key_backup.cpp
src/key_client.cpp
src/key_client_models.cpp
src/key_client_options.cpp
src/key_client_paged_responses.cpp
src/key_curve_name.cpp
src/key_encryption_algorithm.cpp
Expand All @@ -94,6 +114,15 @@ set(
src/key_type.cpp
src/keyvault_key.cpp
src/keyvault_protocol.cpp
src/generated/get_deleted_keys_paged_response.cpp
src/generated/get_keys_paged_response.cpp
src/generated/get_key_versions_paged_response.cpp
src/generated/keys.cpp
src/generated/keys_models.hpp
src/generated/key_vault_client.cpp
src/generated/key_vault_client.hpp
src/generated/key_vault_client_options.hpp
src/generated/key_vault_client_paged_responses.hpp
src/private/cryptography_internal_access.hpp
src/private/cryptography_serializers.hpp
src/private/key_backup.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ namespace Azure { namespace Security { namespace KeyVault { namespace _detail {
}}}} // namespace Azure::Security::KeyVault::_detail

namespace Azure { namespace Security { namespace KeyVault { namespace Keys {

namespace _detail {
class KeyVaultClient;
}
/**
* @brief The KeyClient provides synchronous methods to manage a KeyVaultKe in the Azure Key
* Vault. The client supports creating, retrieving, updating, deleting, purging, backing up,
Expand All @@ -49,6 +51,9 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
/** @brief the HTTP Pipeline used in this KeyClient. */
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;

private:
std::shared_ptr<_detail::KeyVaultClient> m_client;

public:
/**
* @brief Destructor.
Expand Down Expand Up @@ -499,19 +504,5 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
* @return The key client's primary URL endpoint.
*/
std::string GetUrl() const { return m_vaultUrl.GetAbsoluteUrl(); }

private:
std::unique_ptr<Azure::Core::Http::RawResponse> SendRequest(
Azure::Core::Http::Request& request,
Azure::Core::Context const& context) const;

Azure::Core::Http::Request CreateRequest(
Azure::Core::Http::HttpMethod method,
std::vector<std::string> const& path = {},
Azure::Core::IO::BodyStream* content = nullptr) const;

Azure::Core::Http::Request ContinuationTokenRequest(
std::vector<std::string> const& path,
const Azure::Nullable<std::string>& NextPageToken) const;
};
}}}} // namespace Azure::Security::KeyVault::Keys
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,22 @@
#include <vector>

namespace Azure { namespace Security { namespace KeyVault { namespace Keys {

class KeyClient;
namespace _detail {
namespace Models {
struct KeyBundle;
struct DeletedKeyBundle;
struct KeyUpdateParameters;
struct KeyRotationPolicy;
struct KeyItem;
struct DeletedKeyItem;
} // namespace Models
class GetKeysPagedResponse;
class GetKeyVersionsPagedResponse;
class GetDeletedKeysPagedResponse;
} // namespace _detail
class KeyPropertiesPagedResponse;
class DeletedKeyPagedResponse;
/**
* @brief Define a model for a purged key.
*
Expand Down Expand Up @@ -487,7 +502,26 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
*/
std::string EncodedPolicy;
};
/**
* @brief The key attestation information.
*
*/
struct KeyAttestation final
{
/// A base64url-encoded string containing certificates in PEM format, used for attestation
/// validation.
Nullable<std::vector<std::uint8_t>> CertificatePemFile;

/// The attestation blob bytes encoded as base64url string corresponding to a private key.
Nullable<std::vector<std::uint8_t>> PrivateKeyAttestation;

/// The attestation blob bytes encoded as base64url string corresponding to a public key in
/// case of asymmetric key.
Nullable<std::vector<std::uint8_t>> PublicKeyAttestation;

/// The version of the attestation.
Nullable<std::string> Version;
};
/**
* @brief The resource containing all the properties of the KeyVaultKey except JsonWebKey
* properties.
Expand Down Expand Up @@ -596,6 +630,11 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
*/
Azure::Nullable<std::string> HsmPlatform;

/**
* @brief The key or key version attestation information.
*
*/
Azure::Nullable<KeyAttestation> Attestation;
/**
* @brief Construct a new Key Properties object.
*
Expand All @@ -608,6 +647,13 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
* @param name The name of the key.
*/
KeyProperties(std::string name) : Name(std::move(name)) {}

private:
friend class KeyClient;
friend class KeyPropertiesPagedResponse;
_detail::Models::KeyUpdateParameters ToKeyUpdateParameters(
Azure::Nullable<std::vector<KeyOperation>> const& keyOperations) const;
KeyProperties(_detail::Models::KeyItem const& response);
};

/**
Expand Down Expand Up @@ -675,6 +721,10 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
* @return A vector with the supported operations for the key.
*/
std::vector<KeyOperation> const& KeyOperations() const { return Key.KeyOperations(); }

private:
friend class KeyClient;
KeyVaultKey(_detail::Models::KeyBundle const& response);
};

/**
Expand Down Expand Up @@ -714,9 +764,13 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
*
*/
Azure::DateTime ScheduledPurgeDate;
};

class KeyClient;
private:
friend class KeyClient;
friend class DeletedKeyPagedResponse;
DeletedKey(_detail::Models::DeletedKeyBundle const& response);
DeletedKey(_detail::Models::DeletedKeyItem const& response);
};

/**
* @brief Define a single page to list the keys from the Key Vault.
Expand Down Expand Up @@ -755,6 +809,16 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
{
RawResponse = std::move(rawResponse);
}
KeyPropertiesPagedResponse(
_detail::GetKeysPagedResponse const& pagedResponse,
std::unique_ptr<Azure::Core::Http::RawResponse> rawResponse,
std::shared_ptr<KeyClient> keyClient,
std::string const& keyName = std::string());
KeyPropertiesPagedResponse(
_detail::GetKeyVersionsPagedResponse const& pagedResponse,
std::unique_ptr<Azure::Core::Http::RawResponse> rawResponse,
std::shared_ptr<KeyClient> keyClient,
std::string const& keyName = std::string());

public:
/**
Expand Down Expand Up @@ -802,6 +866,10 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
{
RawResponse = std::move(rawResponse);
}
DeletedKeyPagedResponse(
_detail::GetDeletedKeysPagedResponse&& pagedResponse,
std::unique_ptr<Azure::Core::Http::RawResponse> rawResponse,
std::shared_ptr<KeyClient> keyClient);

public:
/**
Expand Down Expand Up @@ -1109,6 +1177,16 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
* @brief The key rotation policy attributes.
*/
KeyRotationPolicyAttributes Attributes;

/**
* @brief Default constructor.
*/
KeyRotationPolicy() = default;

private:
friend class KeyClient;
KeyRotationPolicy(_detail::Models::KeyRotationPolicy const& krp);
_detail::Models::KeyRotationPolicy ToKeyRotationPolicy() const;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
#include <azure/core/internal/client_options.hpp>

namespace Azure { namespace Security { namespace KeyVault { namespace Keys {

class KeyClient;
namespace _detail { namespace Models {
struct KeyCreateParameters;
struct KeyImportParameters;
struct KeyReleaseParameters;
}} // namespace _detail::Models
/**
* @brief The options for calling an operation
* #Azure::Security::KeyVault::Keys::KeyClient::GetPropertiesOfKeys.
Expand Down Expand Up @@ -59,7 +64,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
* @brief Service Version used.
*
*/
std::string ApiVersion{"7.5"};
std::string ApiVersion{"7.6-preview.2"};
};

/**
Expand Down Expand Up @@ -128,6 +133,10 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
*
*/
Azure::Nullable<bool> Exportable;

private:
friend class KeyClient;
_detail::Models::KeyCreateParameters ToKeyCreateParameters() const;
};

/**
Expand Down Expand Up @@ -374,6 +383,10 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
* @return The name of the key.
*/
std::string const& Name() const { return Properties.Name; }

private:
friend class KeyClient;
_detail::Models::KeyImportParameters ToKeyImportParameters() const;
};

/**
Expand Down Expand Up @@ -418,6 +431,10 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
*
*/
Azure::Nullable<std::string> Version;

private:
friend class KeyClient;
_detail::Models::KeyReleaseParameters ToKeyReleaseParameters() const;
};

}}}} // namespace Azure::Security::KeyVault::Keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) TypeSpec Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

#include "key_vault_client.hpp"
#include "key_vault_client_paged_responses.hpp"

using namespace Azure::Security::KeyVault::Keys::_detail;

void GetDeletedKeysPagedResponse::OnNextPage(Core::Context const& context)
{
const auto pageToken = this->NextPageToken;
this->m_options.NextPageToken = pageToken.Value();
*this = this->m_client->GetDeletedKeys(this->m_options, context);
this->CurrentPageToken = pageToken.Value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) TypeSpec Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

#include "key_vault_client.hpp"
#include "key_vault_client_paged_responses.hpp"

using namespace Azure::Security::KeyVault::Keys::_detail;

void GetKeyVersionsPagedResponse::OnNextPage(Core::Context const& context)
{
const auto pageToken = this->NextPageToken;
this->m_options.NextPageToken = pageToken.Value();
*this = this->m_client->GetKeyVersions(this->m_keyName, this->m_options, context);
this->CurrentPageToken = pageToken.Value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) TypeSpec Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

#include "key_vault_client.hpp"
#include "key_vault_client_paged_responses.hpp"

using namespace Azure::Security::KeyVault::Keys::_detail;

void GetKeysPagedResponse::OnNextPage(Core::Context const& context)
{
const auto pageToken = this->NextPageToken;
this->m_options.NextPageToken = pageToken.Value();
*this = this->m_client->GetKeys(this->m_options, context);
this->CurrentPageToken = pageToken.Value();
}
Loading