summaryrefslogtreecommitdiff
path: root/src/common/Cryptography/BigNumber.cpp
diff options
context:
space:
mode:
authorKitzunu <24550914+Kitzunu@users.noreply.github.com>2024-08-07 18:13:31 +0200
committerGitHub <noreply@github.com>2024-08-07 18:13:31 +0200
commitfdd8ff6e04814a1b624cd1ff18093a2c9acaf47c (patch)
treef252968d8efb2201bee163658a8d83a38ac0b85c /src/common/Cryptography/BigNumber.cpp
parent41366fcc69b65c1ecc0bba2cfa05ccb4c5969fa2 (diff)
refactor(Deps/OpenSSL): Deprecate OpenSSL 1.x (#19452)
* EOL
Diffstat (limited to 'src/common/Cryptography/BigNumber.cpp')
-rw-r--r--src/common/Cryptography/BigNumber.cpp32
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