-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(encryption): add kms key management
- Loading branch information
yujingwei
committed
Jan 9, 2024
1 parent
7171159
commit 1c611a6
Showing
68 changed files
with
969 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
#include <string> | ||
|
||
#include "replica/kms_key_provider.h" | ||
#include "utils/errors.h" | ||
|
||
namespace dsn { | ||
namespace security { | ||
|
||
dsn::error_s | ||
KMSKeyProvider::DecryptEncryptionKey(const dsn::replication::replica_kms_info &kms_info, | ||
std::string *decrypted_key) | ||
{ | ||
return client_.DecryptEncryptionKey(kms_info, decrypted_key); | ||
} | ||
|
||
dsn::error_s KMSKeyProvider::GenerateEncryptionKey(dsn::replication::replica_kms_info *kms_info) | ||
{ | ||
return client_.GenerateEncryptionKey(kms_info); | ||
} | ||
|
||
} // namespace security | ||
} // namespace dsn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#include "runtime/security/kms_client.h" | ||
#include "utils/errors.h" | ||
|
||
namespace dsn { | ||
namespace replication { | ||
class replica_kms_info; | ||
} // namespace replication | ||
|
||
namespace security { | ||
// This class generates EEK IV KV from KMS (a.k.a Key Management Service) and retrieves DEK from | ||
// KMS. | ||
class KMSKeyProvider | ||
{ | ||
public: | ||
~KMSKeyProvider() {} | ||
|
||
KMSKeyProvider(const std::vector<std::string> &kms_url, std::string cluster_key_name) | ||
: client_(kms_url, std::move(cluster_key_name)) | ||
{ | ||
} | ||
|
||
// Decrypt the encryption key in 'kms_info' via KMS. The 'decrypted_key' will be a hex string. | ||
dsn::error_s DecryptEncryptionKey(const dsn::replication::replica_kms_info &kms_info, | ||
std::string *decrypted_key); | ||
|
||
// Generate an encryption key from KMS. | ||
dsn::error_s GenerateEncryptionKey(dsn::replication::replica_kms_info *kms_info); | ||
|
||
private: | ||
KMSClient client_; | ||
}; | ||
} // namespace security | ||
} // namespace dsn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.