diff options
| author | Arseny Smirnov <arseny30@gmail.com> | 2020-06-16 18:34:55 +0300 |
|---|---|---|
| committer | Arseny Smirnov <arseny30@gmail.com> | 2020-06-16 18:34:55 +0300 |
| commit | 1a33df9d526bfdeff8709af01c89902f4b9323b1 (patch) | |
| tree | bcc175802b6aa3306714cfae57a50c9a5c1435a2 /tdutils/td/utils/crypto.cpp | |
| parent | 4c288d93989c253c31a38d2f4d203914540d77fd (diff) | |
AesBlock::inc: use bswap64 for x64 and armv8
GitOrigin-RevId: 5842d5d9fd4a865bc0c786e31e3f62f1257d1d4d
Diffstat (limited to 'tdutils/td/utils/crypto.cpp')
| -rw-r--r-- | tdutils/td/utils/crypto.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tdutils/td/utils/crypto.cpp b/tdutils/td/utils/crypto.cpp index f25350530..128f58cd9 100644 --- a/tdutils/td/utils/crypto.cpp +++ b/tdutils/td/utils/crypto.cpp @@ -9,6 +9,7 @@ #include "td/utils/Slice-decl.h" #include "td/utils/as.h" #include "td/utils/BigNum.h" +#include "td/utils/bits.h" #include "td/utils/common.h" #include "td/utils/logging.h" #include "td/utils/misc.h" @@ -79,6 +80,16 @@ struct AesBlock { } AesBlock inc() const { +#if __aarch64__ || __x86_64__ + AesBlock res; + res.lo = native_vs_bigendian64(native_vs_bigendian64(lo) + 1); + if (res.lo == 0) { + res.hi = native_vs_bigendian64(native_vs_bigendian64(hi) + 1); + } else { + res.hi = hi; + } + return res; +#else AesBlock res = *this; auto ptr = res.raw(); if (++ptr[15] == 0) { @@ -89,8 +100,9 @@ struct AesBlock { } } return res; +#endif } -}; +}; // namespace td static_assert(sizeof(AesBlock) == 16, ""); static_assert(sizeof(AesBlock) == AES_BLOCK_SIZE, ""); |
