From 53b0a74f874c515d82fbfb71b089dc2ac3225639 Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Mon, 15 Jun 2020 22:38:31 +0300 Subject: [PATCH] tdutils: revert tosimple AesBlock::inc implementation GitOrigin-RevId: 7f894bb710e32b6573603f3500c35daf0752cf02 --- tdutils/td/utils/crypto.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tdutils/td/utils/crypto.cpp b/tdutils/td/utils/crypto.cpp index 70c2b175a..7dd345cf4 100644 --- a/tdutils/td/utils/crypto.cpp +++ b/tdutils/td/utils/crypto.cpp @@ -78,13 +78,12 @@ struct alignas(8) AesBlock { AesBlock inc() const { AesBlock res; - res.lo = bswap64(bswap64(lo) + 1); - if (res.lo == 0) { - res.hi = bswap64(bswap64(hi) + 1); - } else { - res.hi = hi; + auto ptr = res.raw(); + for (int i = 15; i >= 0; i--) { + if (++ptr[i] != 0) { + break; + } } - return res; } };