mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-24 18:50:49 +00:00
Fix unit tests.
This commit is contained in:
parent
767f1352eb
commit
9517f483bb
@ -38,10 +38,10 @@ class InitVector
|
||||
public:
|
||||
InitVector(String iv_) : iv(FromBigEndianString(iv_)) { }
|
||||
|
||||
const char * GetRef() const
|
||||
const String & GetRef() const
|
||||
{
|
||||
local = ToBigEndianString(iv + counter);
|
||||
return local.data();
|
||||
return local;
|
||||
}
|
||||
|
||||
void Inc() { ++counter; }
|
||||
@ -75,7 +75,7 @@ class EncryptionKey
|
||||
public:
|
||||
EncryptionKey(String key_) : key(key_) { }
|
||||
size_t Size() const { return key.size(); }
|
||||
const char * GetRef() const { return key.data(); }
|
||||
const String & GetRef() const { return key; }
|
||||
|
||||
private:
|
||||
String key;
|
||||
@ -238,8 +238,8 @@ private:
|
||||
throw DB::Exception("Failed to initialize encryption context with cipher", DB::ErrorCodes::DATA_ENCRYPTION_ERROR);
|
||||
|
||||
if (EVP_EncryptInit_ex(evp_ctx, nullptr, nullptr,
|
||||
reinterpret_cast<const unsigned char*>(key.GetRef()),
|
||||
reinterpret_cast<const unsigned char*>(iv.GetRef())) != 1)
|
||||
reinterpret_cast<const unsigned char*>(key.GetRef().data()),
|
||||
reinterpret_cast<const unsigned char*>(iv.GetRef().data())) != 1)
|
||||
throw DB::Exception("Failed to set key and IV for encryption", DB::ErrorCodes::DATA_ENCRYPTION_ERROR);
|
||||
|
||||
int output_len = 0;
|
||||
@ -319,8 +319,8 @@ private:
|
||||
throw DB::Exception("Failed to initialize decryption context with cipher", DB::ErrorCodes::DATA_ENCRYPTION_ERROR);
|
||||
|
||||
if (EVP_DecryptInit_ex(evp_ctx, nullptr, nullptr,
|
||||
reinterpret_cast<const unsigned char*>(key.GetRef()),
|
||||
reinterpret_cast<const unsigned char*>(iv.GetRef())) != 1)
|
||||
reinterpret_cast<const unsigned char*>(key.GetRef().data()),
|
||||
reinterpret_cast<const unsigned char*>(iv.GetRef().data())) != 1)
|
||||
throw DB::Exception("Failed to set key and IV for decryption", DB::ErrorCodes::DATA_ENCRYPTION_ERROR);
|
||||
|
||||
int output_len = 0;
|
||||
|
@ -1,3 +1,7 @@
|
||||
#if !defined(ARCADIA_BUILD)
|
||||
#include <Common/config.h>
|
||||
#endif
|
||||
|
||||
#if USE_SSL
|
||||
#include <gtest/gtest.h>
|
||||
#include <IO/WriteBufferFromString.h>
|
||||
@ -76,16 +80,16 @@ INSTANTIATE_TEST_SUITE_P(InitVectorInputs,
|
||||
1024,
|
||||
string_ends_with(16, "\x1"),
|
||||
string_ends_with(16, "\x56"),
|
||||
string_ends_with(16, "\x4\0"),
|
||||
string_ends_with(16, String("\x4\0", 2)),
|
||||
},
|
||||
{
|
||||
"Long init vector test",
|
||||
"\xa8\x65\x9c\x73\xf8\x5d\x83\xb4\x5c\xa6\x8c\x19\xf4\x77\x80\xe1",
|
||||
UInt128(3349249125638641) * 1815701,
|
||||
3349249125638641,
|
||||
1698923461902341,
|
||||
"\xa8\x65\x9c\x73\xf8\x5d\x83\xb4\x5c\xa6\x8c\x19\xf4\x77\x80\xe2",
|
||||
"\xa8\x65\x9c\x73\xf8\x5d\x84\xfe\x06\xbd\x44\xb7\x0b\x0c\x76\x27",
|
||||
"\xa8\x65\x9c\x73\xf8\x5d\x83\xb4\x5c\xac\x95\x43\x65\xea\x00\xe6",
|
||||
"\xa8\x65\x9c\x73\xf8\x5d\x83\xb4\x5c\xb2\x72\x39\xc8\xdd\x62\xd3",
|
||||
String("\xa8\x65\x9c\x73\xf8\x5d\x83\xb4\x5c\xac\x95\x43\x65\xea\x00\xe6", 16)
|
||||
},
|
||||
})
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user