From efc336e60cf1331bf5f3213d296981b87b8b2a6c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 4 Jun 2023 19:24:05 +0300 Subject: =?UTF-8?q?fixes=20#3537=20(Telegram:=2032-=D1=80=D0=B0=D0=B7?= =?UTF-8?q?=D1=80=D1=8F=D0=B4=D0=BD=D0=B0=D1=8F=20=D0=B2=D0=B5=D1=80=D1=81?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BF=D0=B0=D0=B4=D0=B0=D0=B5=D1=82=20=D0=B2=20?= =?UTF-8?q?64-=D1=80=D0=B0=D0=B7=D1=80=D1=8F=D0=B4=D0=BD=D0=BE=D0=B9=20Win?= =?UTF-8?q?dows)=20+=20update=20to=20the=20fresh=20TDLIB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Telegram/tdlib/td/tdutils/test/crypto.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'protocols/Telegram/tdlib/td/tdutils/test/crypto.cpp') 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 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::min(), std::numeric_limits::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)) { -- cgit v1.2.3