File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 88#include < Common/SipHash.h>
99#include < Common/safe_cast.h>
1010
11- #include < boost/algorithm/string/predicate.hpp>
12- #include < cassert>
13- #include < random>
11+ # include < cassert>
12+ # include < boost/algorithm/string/predicate.hpp>
1413
14+ # include < openssl/err.h>
15+ # include < openssl/rand.h>
1516
1617namespace DB
1718{
@@ -20,6 +21,7 @@ namespace ErrorCodes
2021{
2122 extern const int BAD_ARGUMENTS;
2223 extern const int DATA_ENCRYPTION_ERROR;
24+ extern const int OPENSSL_ERROR;
2325}
2426
2527namespace FileEncryption
@@ -260,12 +262,11 @@ void InitVector::write(WriteBuffer & out) const
260262
261263InitVector InitVector::random ()
262264{
263- std::random_device rd;
264- std::mt19937 gen{rd ()};
265- std::uniform_int_distribution<UInt128::base_type> dis;
266265 UInt128 counter;
267- for (auto & i : counter.items )
268- i = dis (gen);
266+ auto * buf = reinterpret_cast <unsigned char *>(counter.items );
267+ auto ret = RAND_bytes (buf, sizeof (counter.items ));
268+ if (ret != 1 )
269+ throw Exception (DB::ErrorCodes::OPENSSL_ERROR, " OpenSSL error code: {}" , ERR_get_error ());
269270 return InitVector{counter};
270271}
271272
You can’t perform that action at this time.
0 commit comments