aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/openssl/crypto/rsa.cpp
diff options
context:
space:
mode:
authorkomels <komels@yandex-team.ru>2022-04-15 16:53:39 +0300
committerkomels <komels@yandex-team.ru>2022-04-15 16:53:39 +0300
commit703a2fb6e100d202d1c7fcd052d73bd5affef408 (patch)
tree22b7320c06bb04d86dbf7b9af9ae44281331cd15 /library/cpp/openssl/crypto/rsa.cpp
parent3375bbfda1e2afb03aa2072bf5f2f2c3a26026e8 (diff)
downloadydb-703a2fb6e100d202d1c7fcd052d73bd5affef408.tar.gz
Move 'kikimr/yndx'-depending tests out of ydb/core
ref:0a380e13308d579e0545a76924330d1ca5129c43
Diffstat (limited to 'library/cpp/openssl/crypto/rsa.cpp')
-rw-r--r--library/cpp/openssl/crypto/rsa.cpp56
1 files changed, 0 insertions, 56 deletions
diff --git a/library/cpp/openssl/crypto/rsa.cpp b/library/cpp/openssl/crypto/rsa.cpp
deleted file mode 100644
index 350e0c0815..0000000000
--- a/library/cpp/openssl/crypto/rsa.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "rsa.h"
-
-#include <library/cpp/openssl/big_integer/big_integer.h>
-#include <library/cpp/openssl/init/init.h>
-
-#include <util/generic/yexception.h>
-#include <util/generic/buffer.h>
-
-#include <contrib/libs/openssl/include/openssl/bn.h>
-#include <contrib/libs/openssl/include/openssl/rsa.h>
-
-using namespace NOpenSsl;
-using namespace NOpenSsl::NRsa;
-
-namespace {
- struct TInit {
- inline TInit() {
- InitOpenSSL();
- }
- } INIT;
-}
-
-TPublicKey::TPublicKey(const TBigInteger& e, const TBigInteger& n)
- : Key_(RSA_new())
-{
- Y_ENSURE(Key_, "RSA_new() failed");
-
- RSA_set0_key(Key_, BN_dup(n.Impl()), BN_dup(e.Impl()), nullptr);
-}
-
-TPublicKey::~TPublicKey() noexcept {
- RSA_free(Key_);
-}
-
-size_t TPublicKey::OutputLength() const noexcept {
- return RSA_size(Key_);
-}
-
-size_t TPublicKey::EncryptNoPad(void* dst, const void* src, size_t size) const {
- auto len = RSA_public_encrypt(size, (const ui8*)src, (ui8*)dst, Key_, RSA_NO_PADDING);
-
- Y_ENSURE(len >= 0, "RSA_public_encrypt() failed");
-
- return len;
-}
-
-TBigInteger TPublicKey::EncryptNoPad(const TBigInteger& src) const {
- const auto len1 = OutputLength();
- const auto len2 = src.NumBytes();
- TBuffer buf(len1 + len2);
-
- char* buf1 = (char*)buf.Data();
- char* buf2 = buf1 + len1;
-
- return TBigInteger::FromRegion(buf1, EncryptNoPad(buf1, buf2, src.ToRegion(buf2)));
-}