summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/tdutils/test/crypto.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-06-04 19:24:05 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-06-04 19:24:05 +0300
commitefc336e60cf1331bf5f3213d296981b87b8b2a6c (patch)
treeea59ea1a324f45f6e8a06cc0887b376bfba90ca9 /protocols/Telegram/tdlib/td/tdutils/test/crypto.cpp
parent6e83622d2af1cec3c759f4cff6efe4df2fe3328c (diff)
fixes #3537 (Telegram: 32-разрядная версия падает в 64-разрядной Windows) + update to the fresh TDLIB
Diffstat (limited to 'protocols/Telegram/tdlib/td/tdutils/test/crypto.cpp')
-rw-r--r--protocols/Telegram/tdlib/td/tdutils/test/crypto.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/protocols/Telegram/tdlib/td/tdutils/test/crypto.cpp b/protocols/Telegram/tdlib/td/tdutils/test/crypto.cpp
index 9e81ef132c..5b4fd37e69 100644
--- a/protocols/Telegram/tdlib/td/tdutils/test/crypto.cpp
+++ b/protocols/Telegram/tdlib/td/tdutils/test/crypto.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -23,7 +23,7 @@ static td::vector<td::string> strings{"", "1", "short test string", td::string(1
TEST(Crypto, Aes) {
td::Random::Xorshift128plus rnd(123);
td::UInt256 key;
- rnd.bytes(as_slice(key));
+ rnd.bytes(as_mutable_slice(key));
td::string plaintext(16, '\0');
td::string encrypted(16, '\0');
td::string decrypted(16, '\0');
@@ -34,8 +34,8 @@ TEST(Crypto, Aes) {
td::AesState decryptor;
decryptor.init(as_slice(key), false);
- encryptor.encrypt(td::as_slice(plaintext).ubegin(), td::as_slice(encrypted).ubegin(), 16);
- decryptor.decrypt(td::as_slice(encrypted).ubegin(), td::as_slice(decrypted).ubegin(), 16);
+ encryptor.encrypt(td::as_slice(plaintext).ubegin(), td::as_mutable_slice(encrypted).ubegin(), 16);
+ decryptor.decrypt(td::as_slice(encrypted).ubegin(), td::as_mutable_slice(decrypted).ubegin(), 16);
CHECK(decrypted == plaintext);
CHECK(decrypted != encrypted);
@@ -135,7 +135,7 @@ TEST(Crypto, AesIgeState) {
for (const auto &str : td::rand_split(td::string(length / 16, '\0'))) {
auto len = 16 * str.size();
state.encrypt(td::Slice(s).substr(pos, len), td::MutableSlice(t).substr(pos, len));
- td::aes_ige_encrypt(as_slice(key), as_slice(iv_copy), td::Slice(s).substr(pos, len),
+ td::aes_ige_encrypt(as_slice(key), as_mutable_slice(iv_copy), td::Slice(s).substr(pos, len),
td::MutableSlice(u).substr(pos, len));
pos += len;
}
@@ -149,7 +149,7 @@ TEST(Crypto, AesIgeState) {
for (const auto &str : td::rand_split(td::string(length / 16, '\0'))) {
auto len = 16 * str.size();
state.decrypt(td::Slice(t).substr(pos, len), td::MutableSlice(t).substr(pos, len));
- td::aes_ige_decrypt(as_slice(key), as_slice(iv_copy), td::Slice(u).substr(pos, len),
+ td::aes_ige_decrypt(as_slice(key), as_mutable_slice(iv_copy), td::Slice(u).substr(pos, len),
td::MutableSlice(u).substr(pos, len));
pos += len;
}
@@ -191,7 +191,7 @@ TEST(Crypto, AesCbcState) {
for (const auto &str : td::rand_split(td::string(length / 16, '\0'))) {
auto len = 16 * str.size();
state.encrypt(td::Slice(s).substr(pos, len), td::MutableSlice(t).substr(pos, len));
- td::aes_cbc_encrypt(as_slice(key), as_slice(iv_copy), td::Slice(s).substr(pos, len),
+ td::aes_cbc_encrypt(as_slice(key), as_mutable_slice(iv_copy), td::Slice(s).substr(pos, len),
td::MutableSlice(u).substr(pos, len));
pos += len;
}
@@ -205,7 +205,7 @@ TEST(Crypto, AesCbcState) {
for (const auto &str : td::rand_split(td::string(length / 16, '\0'))) {
auto len = 16 * str.size();
state.decrypt(td::Slice(t).substr(pos, len), td::MutableSlice(t).substr(pos, len));
- td::aes_cbc_decrypt(as_slice(key), as_slice(iv_copy), td::Slice(u).substr(pos, len),
+ td::aes_cbc_decrypt(as_slice(key), as_mutable_slice(iv_copy), td::Slice(u).substr(pos, len),
td::MutableSlice(u).substr(pos, len));
pos += len;
}
@@ -221,7 +221,7 @@ TEST(Crypto, Sha256State) {
for (auto length : {0, 1, 31, 32, 33, 9999, 10000, 10001, 999999, 1000001}) {
auto s = td::rand_string(std::numeric_limits<char>::min(), std::numeric_limits<char>::max(), length);
td::UInt256 baseline;
- td::sha256(s, as_slice(baseline));
+ td::sha256(s, as_mutable_slice(baseline));
td::Sha256State state;
state.init();
@@ -232,7 +232,7 @@ TEST(Crypto, Sha256State) {
}
state = std::move(state2);
td::UInt256 result;
- state.extract(as_slice(result));
+ state.extract(as_mutable_slice(result));
ASSERT_TRUE(baseline == result);
}
}
@@ -367,7 +367,7 @@ TEST(Crypto, crc32c_benchmark) {
explicit Crc32cExtendBenchmark(size_t chunk_size) : chunk_size_(chunk_size) {
}
td::string get_description() const final {
- return PSTRING() << "Crc32c with chunk_size=" << chunk_size_;
+ return PSTRING() << "CRC32C with chunk_size = " << chunk_size_;
}
void start_up_n(int n) final {
if (n > (1 << 20)) {