Adding BackupKeyResult struct wrapper as a return type model for BackupKey. (#2619)
* Adding BackupKeyResult struct wrapper as a return type model for BackupKey. * Update sdk/keyvault/azure-security-keyvault-keys/inc/azure/keyvault/keys/backup_key_result.hpp Co-authored-by: Rick Winter <rick.winter@microsoft.com> Co-authored-by: Rick Winter <rick.winter@microsoft.com>
This commit is contained in:
parent
05ebec8b50
commit
a10b507e42
@ -5,6 +5,7 @@
|
||||
### Features Added
|
||||
|
||||
- Added `GetIv()` to `EncryptParameters` and `DecryptParameters`.
|
||||
- Added `BackupKeyResult` for `BackupKey()` return type.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
@ -17,6 +18,7 @@
|
||||
- Removed `Decrypt(DecryptAlgorithm, std::vector, context)`.
|
||||
- Removed the `MaxPageResults` field from `GetPropertiesOfKeysOptions`, `GetPropertiesOfKeyVersionsOptions`, and `GetDeletedKeysOptions`.
|
||||
- Renamed header `list_keys_single_page_result.hpp` to `list_keys_responses.hpp`.
|
||||
- Updated `BackupKey()` API return type to `BackupKeyResult` model type.
|
||||
|
||||
## 4.0.0-beta.3 (2021-06-08)
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ set(
|
||||
inc/azure/keyvault/keys/internal/cryptography/local_cryptography_provider.hpp
|
||||
inc/azure/keyvault/keys/internal/cryptography/remote_cryptography_client.hpp
|
||||
inc/azure/keyvault/keys/internal/cryptography/rsa_cryptography_provider.hpp
|
||||
inc/azure/keyvault/keys/backup_key_result.hpp
|
||||
inc/azure/keyvault/keys/delete_key_operation.hpp
|
||||
inc/azure/keyvault/keys/deleted_key.hpp
|
||||
inc/azure/keyvault/keys/import_key_options.hpp
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Defines the BackupKey model type.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
|
||||
/**
|
||||
* @brief The BackupKeyResult type containing the backup key of bytes.
|
||||
*
|
||||
*/
|
||||
struct BackupKeyResult final
|
||||
{
|
||||
/**
|
||||
* @brief The backup key array data.
|
||||
*
|
||||
*/
|
||||
std::vector<uint8_t> BackupKey;
|
||||
};
|
||||
|
||||
}}}} // namespace Azure::Security::KeyVault::Keys
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
#include <azure/keyvault/common/internal/keyvault_pipeline.hpp>
|
||||
|
||||
#include "azure/keyvault/keys/backup_key_result.hpp"
|
||||
#include "azure/keyvault/keys/delete_key_operation.hpp"
|
||||
#include "azure/keyvault/keys/import_key_options.hpp"
|
||||
#include "azure/keyvault/keys/key_client_options.hpp"
|
||||
@ -341,7 +342,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
* @param name The name of the key.
|
||||
* @param context A #Azure::Core::Context controlling the request lifetime.
|
||||
*/
|
||||
Azure::Response<std::vector<uint8_t>> BackupKey(
|
||||
Azure::Response<Azure::Security::KeyVault::Keys::BackupKeyResult> BackupKey(
|
||||
std::string const& name,
|
||||
Azure::Core::Context const& context = Azure::Core::Context()) const;
|
||||
|
||||
|
||||
@ -320,7 +320,7 @@ Azure::Response<KeyVaultKey> KeyClient::UpdateKeyProperties(
|
||||
{_detail::KeysPath, properties.Name, properties.Version});
|
||||
}
|
||||
|
||||
Azure::Response<std::vector<uint8_t>> KeyClient::BackupKey(
|
||||
Azure::Response<Azure::Security::KeyVault::Keys::BackupKeyResult> KeyClient::BackupKey(
|
||||
std::string const& name,
|
||||
Azure::Core::Context const& context) const
|
||||
{
|
||||
@ -334,8 +334,9 @@ Azure::Response<std::vector<uint8_t>> KeyClient::BackupKey(
|
||||
{_detail::KeysPath, name, "backup"});
|
||||
|
||||
// Convert the internal KeyBackup model to a raw vector<uint8_t>.
|
||||
return Azure::Response<std::vector<uint8_t>>(
|
||||
response.Value.Value, std::move(response.RawResponse));
|
||||
return Azure::Response<Azure::Security::KeyVault::Keys::BackupKeyResult>(
|
||||
Azure::Security::KeyVault::Keys::BackupKeyResult{response.Value.Value},
|
||||
std::move(response.RawResponse));
|
||||
}
|
||||
|
||||
Azure::Response<KeyVaultKey> KeyClient::RestoreKeyBackup(
|
||||
|
||||
@ -54,7 +54,7 @@ int main()
|
||||
size_t backUpSize = 0;
|
||||
{
|
||||
std::cout << "\t-Backup Key" << std::endl;
|
||||
std::vector<uint8_t> backupKey(keyClient.BackupKey(rsaKeyName).Value);
|
||||
std::vector<uint8_t> backupKey(keyClient.BackupKey(rsaKeyName).Value.BackupKey);
|
||||
backUpSize = backupKey.size();
|
||||
|
||||
// save data to file
|
||||
|
||||
@ -61,7 +61,7 @@ TEST_F(KeyVaultClientTest, BackupKey)
|
||||
{
|
||||
// Restore
|
||||
std::cout << std::endl << "- Restore key";
|
||||
auto respone = keyClient.RestoreKeyBackup(backUpResponse.Value);
|
||||
auto respone = keyClient.RestoreKeyBackup(backUpResponse.Value.BackupKey);
|
||||
CheckValidResponse(backUpResponse);
|
||||
}
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user