aboutsummaryrefslogtreecommitdiff
path: root/src/common/Cryptography
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/Cryptography')
-rw-r--r--src/common/Cryptography/BigNumber.cpp6
-rw-r--r--src/common/Cryptography/BigNumber.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/src/common/Cryptography/BigNumber.cpp b/src/common/Cryptography/BigNumber.cpp
index f220ca319be..66071006a7f 100644
--- a/src/common/Cryptography/BigNumber.cpp
+++ b/src/common/Cryptography/BigNumber.cpp
@@ -61,6 +61,12 @@ void BigNumber::SetBinary(uint8 const* bytes, int32 len, bool littleEndian)
BN_bin2bn(bytes, len, _bn);
}
+bool BigNumber::SetDecStr(char const* str)
+{
+ int n = BN_dec2bn(&_bn, str);
+ return n > 0;
+}
+
bool BigNumber::SetHexStr(char const* str)
{
int n = BN_hex2bn(&_bn, str);
diff --git a/src/common/Cryptography/BigNumber.h b/src/common/Cryptography/BigNumber.h
index 3ec6cc65590..3815339d9cf 100644
--- a/src/common/Cryptography/BigNumber.h
+++ b/src/common/Cryptography/BigNumber.h
@@ -46,6 +46,8 @@ class TC_COMMON_API BigNumber
void SetBinary(uint8 const* bytes, int32 len, bool littleEndian = true);
template <typename Container>
auto SetBinary(Container const& c, bool littleEndian = true) -> std::enable_if_t<!std::is_pointer_v<std::decay_t<Container>>> { SetBinary(std::data(c), std::size(c), littleEndian); }
+ bool SetDecStr(char const* str);
+ bool SetDecStr(std::string const& str) { return SetDecStr(str.c_str()); }
bool SetHexStr(char const* str);
bool SetHexStr(std::string const& str) { return SetHexStr(str.c_str()); }