aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSemyon Danilov <senya@ydb.tech>2024-11-21 14:58:27 +0100
committerGitHub <noreply@github.com>2024-11-21 14:58:27 +0100
commit3541f4a25a78607baf70aeccc0f28f36e5717bc2 (patch)
treec577d8d659588cbd28821cdb98449b47156f2036
parentb76c6f851fa9f8609a3e99409ad50b962626b561 (diff)
downloadydb-3541f4a25a78607baf70aeccc0f28f36e5717bc2.tar.gz
Fix blobstorage crypto module build for aarch64 (#11840)
-rw-r--r--ydb/core/blobstorage/crypto/crypto.cpp11
-rw-r--r--ydb/core/blobstorage/crypto/crypto.h8
2 files changed, 8 insertions, 11 deletions
diff --git a/ydb/core/blobstorage/crypto/crypto.cpp b/ydb/core/blobstorage/crypto/crypto.cpp
index 134fc29c5f..1317511b12 100644
--- a/ydb/core/blobstorage/crypto/crypto.cpp
+++ b/ydb/core/blobstorage/crypto/crypto.cpp
@@ -173,14 +173,14 @@ const bool TStreamCypher::HasAVX512 = NX86::HaveAVX512F();
Y_FORCE_INLINE void TStreamCypher::Encipher(const ui8* plaintext, ui8* ciphertext, size_t len) {
std::visit([&](auto&& chacha) {
chacha.Encipher(plaintext, ciphertext, len);
- }, *Cypher);
+ }, Cypher);
}
Y_FORCE_INLINE void TStreamCypher::SetKeyAndIV(const ui64 blockIdx) {
std::visit([&](auto&& chacha) {
chacha.SetKey((ui8*)&Key[0], sizeof(Key));
chacha.SetIV((ui8*)&Nonce, (ui8*)&blockIdx);
- }, *Cypher);
+ }, Cypher);
}
TStreamCypher::TStreamCypher()
@@ -189,15 +189,12 @@ TStreamCypher::TStreamCypher()
{
#if ENABLE_ENCRYPTION
memset(Key, 0, sizeof(Key));
-
- auto* chacha = new std::variant<ChaChaVec, ChaCha512>;
if (HasAVX512) {
- chacha->emplace<ChaCha512>(CYPHER_ROUNDS);
+ Cypher.emplace<ChaCha512>(CYPHER_ROUNDS);
} else {
- chacha->emplace<ChaChaVec>(CYPHER_ROUNDS);
+ Cypher.emplace<ChaChaVec>(CYPHER_ROUNDS);
}
- Cypher.reset(chacha);
#else
Y_UNUSED(Leftover);
Y_UNUSED(Key);
diff --git a/ydb/core/blobstorage/crypto/crypto.h b/ydb/core/blobstorage/crypto/crypto.h
index b57e7935d1..6eceee8f75 100644
--- a/ydb/core/blobstorage/crypto/crypto.h
+++ b/ydb/core/blobstorage/crypto/crypto.h
@@ -7,10 +7,10 @@
#if (defined(_win_) || defined(_arm64_))
#include <ydb/core/blobstorage/crypto/chacha.h>
#include <ydb/core/blobstorage/crypto/poly1305.h>
-#define ChaChaVec ChaCha
-#define ChaCha512 ChaCha
-#define Poly1305Vec Poly1305
#define CHACHA_BPI 1
+using ChaChaVec = ChaCha;
+using Poly1305Vec = Poly1305;
+class ChaCha512 : public ChaCha {};
#else
#include <ydb/core/blobstorage/crypto/chacha_vec.h>
#include <ydb/core/blobstorage/crypto/chacha_512/chacha_512.h>
@@ -104,7 +104,7 @@ private:
alignas(16) ui8 Leftover[BLOCK_BYTES];
alignas(16) ui64 Key[4];
alignas(16) i64 Nonce;
- std::unique_ptr<std::variant<ChaChaVec, ChaCha512>> Cypher;
+ std::variant<ChaChaVec, ChaCha512> Cypher;
ui32 UnusedBytes;
public:
TStreamCypher();