File tree 2 files changed +8
-11
lines changed
ydb/core/blobstorage/crypto
2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -173,14 +173,14 @@ const bool TStreamCypher::HasAVX512 = NX86::HaveAVX512F();
173
173
Y_FORCE_INLINE void TStreamCypher::Encipher (const ui8* plaintext, ui8* ciphertext, size_t len) {
174
174
std::visit ([&](auto && chacha) {
175
175
chacha.Encipher (plaintext, ciphertext, len);
176
- }, * Cypher);
176
+ }, Cypher);
177
177
}
178
178
179
179
Y_FORCE_INLINE void TStreamCypher::SetKeyAndIV (const ui64 blockIdx) {
180
180
std::visit ([&](auto && chacha) {
181
181
chacha.SetKey ((ui8*)&Key[0 ], sizeof (Key));
182
182
chacha.SetIV ((ui8*)&Nonce, (ui8*)&blockIdx);
183
- }, * Cypher);
183
+ }, Cypher);
184
184
}
185
185
186
186
TStreamCypher::TStreamCypher ()
@@ -189,15 +189,12 @@ TStreamCypher::TStreamCypher()
189
189
{
190
190
#if ENABLE_ENCRYPTION
191
191
memset (Key, 0 , sizeof (Key));
192
-
193
- auto * chacha = new std::variant<ChaChaVec, ChaCha512>;
194
192
195
193
if (HasAVX512) {
196
- chacha-> emplace <ChaCha512>(CYPHER_ROUNDS);
194
+ Cypher. emplace <ChaCha512>(CYPHER_ROUNDS);
197
195
} else {
198
- chacha-> emplace <ChaChaVec>(CYPHER_ROUNDS);
196
+ Cypher. emplace <ChaChaVec>(CYPHER_ROUNDS);
199
197
}
200
- Cypher.reset (chacha);
201
198
#else
202
199
Y_UNUSED (Leftover);
203
200
Y_UNUSED (Key);
Original file line number Diff line number Diff line change 7
7
#if (defined(_win_) || defined(_arm64_))
8
8
#include < ydb/core/blobstorage/crypto/chacha.h>
9
9
#include < ydb/core/blobstorage/crypto/poly1305.h>
10
- #define ChaChaVec ChaCha
11
- #define ChaCha512 ChaCha
12
- #define Poly1305Vec Poly1305
13
10
#define CHACHA_BPI 1
11
+ using ChaChaVec = ChaCha;
12
+ using Poly1305Vec = Poly1305;
13
+ class ChaCha512 : public ChaCha {};
14
14
#else
15
15
#include < ydb/core/blobstorage/crypto/chacha_vec.h>
16
16
#include < ydb/core/blobstorage/crypto/chacha_512/chacha_512.h>
@@ -104,7 +104,7 @@ class TStreamCypher {
104
104
alignas (16 ) ui8 Leftover[BLOCK_BYTES];
105
105
alignas (16 ) ui64 Key[4 ];
106
106
alignas (16 ) i64 Nonce;
107
- std::unique_ptr<std:: variant<ChaChaVec, ChaCha512> > Cypher;
107
+ std::variant<ChaChaVec, ChaCha512> Cypher;
108
108
ui32 UnusedBytes;
109
109
public:
110
110
TStreamCypher ();
You can’t perform that action at this time.
0 commit comments