Skip to content

Commit 3541f4a

Browse files
authored
Fix blobstorage crypto module build for aarch64 (#11840)
1 parent b76c6f8 commit 3541f4a

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

ydb/core/blobstorage/crypto/crypto.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,14 @@ const bool TStreamCypher::HasAVX512 = NX86::HaveAVX512F();
173173
Y_FORCE_INLINE void TStreamCypher::Encipher(const ui8* plaintext, ui8* ciphertext, size_t len) {
174174
std::visit([&](auto&& chacha) {
175175
chacha.Encipher(plaintext, ciphertext, len);
176-
}, *Cypher);
176+
}, Cypher);
177177
}
178178

179179
Y_FORCE_INLINE void TStreamCypher::SetKeyAndIV(const ui64 blockIdx) {
180180
std::visit([&](auto&& chacha) {
181181
chacha.SetKey((ui8*)&Key[0], sizeof(Key));
182182
chacha.SetIV((ui8*)&Nonce, (ui8*)&blockIdx);
183-
}, *Cypher);
183+
}, Cypher);
184184
}
185185

186186
TStreamCypher::TStreamCypher()
@@ -189,15 +189,12 @@ TStreamCypher::TStreamCypher()
189189
{
190190
#if ENABLE_ENCRYPTION
191191
memset(Key, 0, sizeof(Key));
192-
193-
auto* chacha = new std::variant<ChaChaVec, ChaCha512>;
194192

195193
if (HasAVX512) {
196-
chacha->emplace<ChaCha512>(CYPHER_ROUNDS);
194+
Cypher.emplace<ChaCha512>(CYPHER_ROUNDS);
197195
} else {
198-
chacha->emplace<ChaChaVec>(CYPHER_ROUNDS);
196+
Cypher.emplace<ChaChaVec>(CYPHER_ROUNDS);
199197
}
200-
Cypher.reset(chacha);
201198
#else
202199
Y_UNUSED(Leftover);
203200
Y_UNUSED(Key);

ydb/core/blobstorage/crypto/crypto.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#if (defined(_win_) || defined(_arm64_))
88
#include <ydb/core/blobstorage/crypto/chacha.h>
99
#include <ydb/core/blobstorage/crypto/poly1305.h>
10-
#define ChaChaVec ChaCha
11-
#define ChaCha512 ChaCha
12-
#define Poly1305Vec Poly1305
1310
#define CHACHA_BPI 1
11+
using ChaChaVec = ChaCha;
12+
using Poly1305Vec = Poly1305;
13+
class ChaCha512 : public ChaCha {};
1414
#else
1515
#include <ydb/core/blobstorage/crypto/chacha_vec.h>
1616
#include <ydb/core/blobstorage/crypto/chacha_512/chacha_512.h>
@@ -104,7 +104,7 @@ class TStreamCypher {
104104
alignas(16) ui8 Leftover[BLOCK_BYTES];
105105
alignas(16) ui64 Key[4];
106106
alignas(16) i64 Nonce;
107-
std::unique_ptr<std::variant<ChaChaVec, ChaCha512>> Cypher;
107+
std::variant<ChaChaVec, ChaCha512> Cypher;
108108
ui32 UnusedBytes;
109109
public:
110110
TStreamCypher();

0 commit comments

Comments
 (0)