diff options
author | komels <komels@yandex-team.ru> | 2022-04-15 16:53:39 +0300 |
---|---|---|
committer | komels <komels@yandex-team.ru> | 2022-04-15 16:53:39 +0300 |
commit | 703a2fb6e100d202d1c7fcd052d73bd5affef408 (patch) | |
tree | 22b7320c06bb04d86dbf7b9af9ae44281331cd15 /library/cpp/openssl/big_integer/big_integer.cpp | |
parent | 3375bbfda1e2afb03aa2072bf5f2f2c3a26026e8 (diff) | |
download | ydb-703a2fb6e100d202d1c7fcd052d73bd5affef408.tar.gz |
Move 'kikimr/yndx'-depending tests out of ydb/core
ref:0a380e13308d579e0545a76924330d1ca5129c43
Diffstat (limited to 'library/cpp/openssl/big_integer/big_integer.cpp')
-rw-r--r-- | library/cpp/openssl/big_integer/big_integer.cpp | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/library/cpp/openssl/big_integer/big_integer.cpp b/library/cpp/openssl/big_integer/big_integer.cpp deleted file mode 100644 index de59f84499..0000000000 --- a/library/cpp/openssl/big_integer/big_integer.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "big_integer.h" - -#include <util/generic/yexception.h> -#include <util/generic/scope.h> -#include <util/stream/output.h> - -#include <contrib/libs/openssl/include/openssl/bn.h> - -using namespace NOpenSsl; - -TBigInteger::~TBigInteger() noexcept { - BN_free(Impl_); -} - -TBigInteger TBigInteger::FromULong(ui64 value) { - TBigInteger result(BN_new()); - - Y_ENSURE(result.Impl(), "BN_new() failed"); - Y_ENSURE(BN_set_word(result.Impl(), value) == 1, "BN_set_word() failed"); - - return result; -} - -TBigInteger TBigInteger::FromRegion(const void* ptr, size_t len) { - auto result = BN_bin2bn((ui8*)(ptr), len, nullptr); - - Y_ENSURE(result, "BN_bin2bn() failed"); - - return result; -} - -int TBigInteger::Compare(const TBigInteger& a, const TBigInteger& b) noexcept { - return BN_cmp(a.Impl(), b.Impl()); -} - -size_t TBigInteger::NumBytes() const noexcept { - return BN_num_bytes(Impl_); -} - -size_t TBigInteger::ToRegion(void* to) const noexcept { - const auto ret = BN_bn2bin(Impl_, (unsigned char*)to); - - Y_VERIFY(ret >= 0, "it happens"); - - return ret; -} - -TString TBigInteger::ToDecimalString() const { - auto res = BN_bn2dec(Impl_); - - Y_DEFER { - OPENSSL_free(res); - }; - - return res; -} - -template <> -void Out<TBigInteger>(IOutputStream& out, const TBigInteger& bi) { - out << bi.ToDecimalString(); -} |