diff options
author | Treeston <treeston.mmoc@gmail.com> | 2020-07-26 05:15:43 +0200 |
---|---|---|
committer | Treeston <treeston.mmoc@gmail.com> | 2020-07-26 05:15:43 +0200 |
commit | 5e36bf7c67e077bd1664eee59d5758fbae7666cd (patch) | |
tree | 345bb7765cada524621890f3ad6494e2c52d7166 /src/common/Cryptography/BigNumber.h | |
parent | 210176fd915cf4ba16f428d3c1a249a71f4aa7a7 (diff) |
Core/Authserver: Auth cleanup phase 1a, the "stuff I ran across while making phase 2" commit.
- Did you know BigNumber quietly assumes every byte array it gets is little-endian, even though openssl bignums use big-endian? Now you do!
- In entirely unrelated news, make the above behavior explicit through a default-true boolean, same as existing GetBytes derivatives.
- Also, if you are in the enlightened openssl 1.1 crowd, there's no more endian wrangling involved, because openssl now does all of that for us. Progress!
Diffstat (limited to 'src/common/Cryptography/BigNumber.h')
-rw-r--r-- | src/common/Cryptography/BigNumber.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/common/Cryptography/BigNumber.h b/src/common/Cryptography/BigNumber.h index ef9281b4652..1152b468ac8 100644 --- a/src/common/Cryptography/BigNumber.h +++ b/src/common/Cryptography/BigNumber.h @@ -34,15 +34,15 @@ class TC_COMMON_API BigNumber BigNumber(uint32 v) : BigNumber() { SetDword(v); } BigNumber(std::string const& v) : BigNumber() { SetHexStr(v); } template <size_t Size> - BigNumber(std::array<uint8, Size> const& v) : BigNumber() { SetBinary(v.data(), Size); } + BigNumber(std::array<uint8, Size> const& v, bool littleEndian = true) : BigNumber() { SetBinary(v.data(), Size, littleEndian); } ~BigNumber(); void SetDword(uint32); void SetQword(uint64); - void SetBinary(uint8 const* bytes, int32 len); + void SetBinary(uint8 const* bytes, int32 len, bool littleEndian = true); template <typename Container> - void SetBinary(Container const& c) { SetBinary(std::data(c), std::size(c)); } + auto SetBinary(Container const& c, bool littleEndian = true) -> std::enable_if_t<!std::is_pointer_v<Container>> { SetBinary(std::data(c), std::size(c), littleEndian); } bool SetHexStr(char const* str); bool SetHexStr(std::string const& str) { return SetHexStr(str.c_str()); } |