From 287e18a57c3bf4cda7dbd03fd19cb5eb85e56eb7 Mon Sep 17 00:00:00 2001 From: Treeston Date: Sun, 26 Jul 2020 05:20:41 +0200 Subject: Core/Authserver: Auth cleanup phase 1b, the "I didn't hit Stage All" commit. Sorry. (5e36bf7 follow-up) (cherry picked from commit 4f570e5d08d0338ac16aace81865c04b0605b0a5) --- src/common/Cryptography/BigNumber.cpp | 2 +- src/common/Utilities/Util.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/Cryptography/BigNumber.cpp b/src/common/Cryptography/BigNumber.cpp index 613cd49ae3f..e0241c77486 100644 --- a/src/common/Cryptography/BigNumber.cpp +++ b/src/common/Cryptography/BigNumber.cpp @@ -198,7 +198,7 @@ void BigNumber::GetBytes(uint8* buf, size_t bufsize, bool littleEndian) const std::reverse(buf, buf + bufsize); #else int res = littleEndian ? BN_bn2lebinpad(_bn, buf, bufsize) : BN_bn2binpad(_bn, buf, bufsize); - ASSERT(res > 0, "Buffer of size %zu is too small to hold bignum with %zu bytes.\n", bufsize, BN_num_bytes(_bn)); + ASSERT(res > 0, "Buffer of size %zu is too small to hold bignum with %d bytes.\n", bufsize, BN_num_bytes(_bn)); #endif } diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h index b3270eb6c2c..9592f36a7b7 100644 --- a/src/common/Utilities/Util.h +++ b/src/common/Utilities/Util.h @@ -20,6 +20,7 @@ #include "Define.h" #include "Errors.h" +#include #include #include #include "advstd.h" @@ -306,6 +307,19 @@ TC_COMMON_API std::string ByteArrayToHexStr(uint8 const* bytes, size_t length, b template std::string ByteArrayToHexStr(Container const& c, bool reverse = false) { return ByteArrayToHexStr(advstd::data(c), advstd::size(c), reverse); } TC_COMMON_API void HexStrToByteArray(std::string const& str, uint8* out, bool reverse = false); +template +void HexStrToByteArray(std::string const& str, std::array& buf, bool reverse = false) +{ + ASSERT(str.size() == (2 * Size)); + HexStrToByteArray(str, buf.data(), reverse); +} +template +std::array HexStrToByteArray(std::string const& str, bool reverse = false) +{ + std::array arr; + HexStrToByteArray(str, arr, reverse); + return arr; +} TC_COMMON_API bool StringToBool(std::string const& str); TC_COMMON_API float DegToRad(float degrees); -- cgit v1.2.3