-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23-3 local disk with encryption (#1760)
* Fix depends (#1582) * Show keyhash on monpage (#1587) * Show keyhash on monpage * Fix review issues * Pass encryption key info to external-vhost server (#1622) * Pass encryption key info to external-vhost server * Fix and tests * Fix review issues * Fix race with background thread (#1641) * Fix depends (#1654) * Use smart pointers for memory mangement (#1662) * Small fixes * Use unique_ptr for memory management * Fix creation call * Fix review issues * Open endpoint with cgroups (#1671) * VHost aio backend encryption (#1675) * VHost aio backend encryption * Log message on error * Tests in server_ut.cpp * Write zero blocks * Return VHD_BDEV_IOERR on enryption/decryption error * Abort process when can't get encryption key * Tests * Fix review issues * Add test and clang-format * Fix ASAN * Remove unnecessary changes * Fix tsan tests for vhost-server (#1682) * Use backoff delay when restart external-vhost-server (#1698) * Use backoff delay when restart external-vhost-server * Make constants * Do not write that we will restart if we are not going to do it * Fix MSAN wrong assumption for AIO reading (#1719) * Vhost server write encrypted zero blocks (#1728) * Write encrypted zero-block * Stats about encryptor errors and generated zero blocks * Use constexpr * Transfer critical events to NBS * Fix typo * Limit crit event storage size * Fix review issues * Fix test * Fix compilation #1 * Fix compilation #2 * Fix compilation #3 * Fix compilation #4 * Fix compilation #5
- Loading branch information
Showing
46 changed files
with
1,930 additions
and
545 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "utils.h" | ||
|
||
#include <util/generic/map.h> | ||
#include <util/generic/yexception.h> | ||
|
||
namespace NCloud::NBlockStore { | ||
|
||
namespace { | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
const TMap<TString, NProto::EEncryptionMode> EncryptionModes = { | ||
{"no", NProto::NO_ENCRYPTION}, | ||
{"aes-xts", NProto::ENCRYPTION_AES_XTS}, | ||
}; | ||
|
||
} // namespace | ||
|
||
NProto::EEncryptionMode EncryptionModeFromString(const TString& str) | ||
{ | ||
auto it = EncryptionModes.find(str); | ||
if (it != EncryptionModes.end()) { | ||
return it->second; | ||
} | ||
|
||
ythrow yexception() << "invalid encryption mode: " << str; | ||
} | ||
|
||
TString EncryptionModeToString(NProto::EEncryptionMode encryptionMode) | ||
{ | ||
for (const auto& [key, value]: EncryptionModes) { | ||
if (value == encryptionMode) { | ||
return key; | ||
} | ||
} | ||
ythrow yexception() << "invalid encryption mode: " | ||
<< static_cast<int>(encryptionMode); | ||
} | ||
|
||
NProto::TEncryptionSpec CreateEncryptionSpec( | ||
NProto::EEncryptionMode mode, | ||
const TString& keyPath, | ||
const TString& keyHash) | ||
{ | ||
if (mode == NProto::NO_ENCRYPTION) { | ||
Y_ENSURE( | ||
keyHash.empty() && keyPath.empty(), | ||
"invalid encryption options: set encryption mode or remove key " | ||
"hash and key path"); | ||
return {}; | ||
} | ||
|
||
Y_ENSURE( | ||
keyHash.empty() || keyPath.empty(), | ||
"invalid encryption options: set key path or key hash, not both"); | ||
|
||
Y_ENSURE( | ||
keyHash || keyPath, | ||
"invalid encryption options: set key hash or key path or remove " | ||
"encryption mode"); | ||
|
||
NProto::TEncryptionSpec encryptionSpec; | ||
encryptionSpec.SetMode(mode); | ||
encryptionSpec.SetKeyHash(keyHash); | ||
encryptionSpec.MutableKeyPath()->SetFilePath(keyPath); | ||
return encryptionSpec; | ||
} | ||
|
||
} // namespace NCloud::NBlockStore |
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,16 @@ | ||
#pragma once | ||
|
||
#include <cloud/blockstore/public/api/protos/encryption.pb.h> | ||
|
||
namespace NCloud::NBlockStore { | ||
|
||
NProto::EEncryptionMode EncryptionModeFromString(const TString& str); | ||
|
||
TString EncryptionModeToString(NProto::EEncryptionMode encryptionMode); | ||
|
||
NProto::TEncryptionSpec CreateEncryptionSpec( | ||
NProto::EEncryptionMode mode, | ||
const TString& keyPath, | ||
const TString& keyHash); | ||
|
||
} // namespace NCloud::NBlockStore |
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,11 @@ | ||
LIBRARY() | ||
|
||
SRCS( | ||
utils.cpp | ||
) | ||
|
||
PEERDIR( | ||
cloud/blockstore/public/api/protos | ||
) | ||
|
||
END() |
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.