diff options
Diffstat (limited to 'src/common/Cryptography/BigNumber.cpp')
-rw-r--r-- | src/common/Cryptography/BigNumber.cpp | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/src/common/Cryptography/BigNumber.cpp b/src/common/Cryptography/BigNumber.cpp index decfeecbe5..9f9d9a9175 100644 --- a/src/common/Cryptography/BigNumber.cpp +++ b/src/common/Cryptography/BigNumber.cpp @@ -57,20 +57,7 @@ void BigNumber::SetQword(uint64 val) void BigNumber::SetBinary(uint8 const* bytes, int32 len, bool littleEndian) { if (littleEndian) - { -#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L - uint8* array = new uint8[len]; - - for (int i = 0; i < len; i++) - array[i] = bytes[len - 1 - i]; - - BN_bin2bn(array, len, _bn); - - delete[] array; -#else BN_lebin2bn(bytes, len, _bn); -#endif - } else BN_bin2bn(bytes, len, _bn); } @@ -197,27 +184,8 @@ bool BigNumber::IsNegative() const void BigNumber::GetBytes(uint8* buf, std::size_t bufsize, bool littleEndian) const { -#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L - int nBytes = GetNumBytes(); - ASSERT(nBytes >= 0, "Bignum has negative number of bytes ({}).", nBytes); - std::size_t numBytes = static_cast<std::size_t>(nBytes); - - // too large to store - ASSERT(numBytes <= bufsize, "Buffer of size {} is too small to hold bignum with {} bytes.\n", bufsize, numBytes); - - // If we need more bytes than length of BigNumber set the rest to 0 - if (numBytes < bufsize) - memset((void*)buf, 0, bufsize); - - BN_bn2bin(_bn, buf + (bufsize - numBytes)); - - // openssl's BN stores data internally in big endian format, reverse if little endian desired - if (littleEndian) - 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 {} is too small to hold bignum with {} bytes.\n", bufsize, BN_num_bytes(_bn)); -#endif } std::vector<uint8> BigNumber::ToByteVector(int32 minSize, bool littleEndian) const |