aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/openssl
diff options
context:
space:
mode:
authordeshevoy <deshevoy@yandex-team.ru>2022-02-10 16:46:56 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:56 +0300
commite988f30484abe5fdeedcc7a5d3c226c01a21800c (patch)
tree0a217b173aabb57b7e51f8a169989b1a3e0309fe /library/cpp/openssl
parent33ee501c05d3f24036ae89766a858930ae66c548 (diff)
downloadydb-e988f30484abe5fdeedcc7a5d3c226c01a21800c.tar.gz
Restoring authorship annotation for <deshevoy@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/openssl')
-rw-r--r--library/cpp/openssl/holders/bio.cpp56
-rw-r--r--library/cpp/openssl/holders/bio.h48
-rw-r--r--library/cpp/openssl/holders/bn.h26
-rw-r--r--library/cpp/openssl/holders/evp.h26
-rw-r--r--library/cpp/openssl/holders/hmac.h20
-rw-r--r--library/cpp/openssl/holders/holder.h62
-rw-r--r--library/cpp/openssl/holders/ut/evp_ut.cpp28
-rw-r--r--library/cpp/openssl/holders/ut/hmac_ut.cpp18
-rw-r--r--library/cpp/openssl/holders/ut/ya.make18
-rw-r--r--library/cpp/openssl/holders/x509_vfy.cpp60
-rw-r--r--library/cpp/openssl/holders/x509_vfy.h48
-rw-r--r--library/cpp/openssl/holders/ya.make32
-rw-r--r--library/cpp/openssl/init/init.cpp6
-rw-r--r--library/cpp/openssl/io/stream.cpp58
-rw-r--r--library/cpp/openssl/method/io.cpp242
-rw-r--r--library/cpp/openssl/method/io.h60
-rw-r--r--library/cpp/openssl/method/ut/io_ut.cpp100
-rw-r--r--library/cpp/openssl/method/ut/ya.make16
-rw-r--r--library/cpp/openssl/method/ya.make26
-rw-r--r--library/cpp/openssl/ya.make8
20 files changed, 479 insertions, 479 deletions
diff --git a/library/cpp/openssl/holders/bio.cpp b/library/cpp/openssl/holders/bio.cpp
index 42cc5fc1ef..5b4eba8234 100644
--- a/library/cpp/openssl/holders/bio.cpp
+++ b/library/cpp/openssl/holders/bio.cpp
@@ -1,29 +1,29 @@
-#include "bio.h"
-
-namespace NOpenSSL {
-
- TBioMethod::TBioMethod(
- int type,
- const char* name,
- int (*write)(BIO*, const char*, int),
- int (*read)(BIO*, char*, int),
- int (*puts)(BIO*, const char*),
- int (*gets)(BIO*, char*, int),
- long (*ctrl)(BIO*, int, long, void*),
- int (*create)(BIO*),
- int (*destroy)(BIO*),
- long (*callbackCtrl)(BIO*, int, bio_info_cb*)
- )
- : THolder(type, name)
- {
+#include "bio.h"
+
+namespace NOpenSSL {
+
+ TBioMethod::TBioMethod(
+ int type,
+ const char* name,
+ int (*write)(BIO*, const char*, int),
+ int (*read)(BIO*, char*, int),
+ int (*puts)(BIO*, const char*),
+ int (*gets)(BIO*, char*, int),
+ long (*ctrl)(BIO*, int, long, void*),
+ int (*create)(BIO*),
+ int (*destroy)(BIO*),
+ long (*callbackCtrl)(BIO*, int, bio_info_cb*)
+ )
+ : THolder(type, name)
+ {
BIO_meth_set_write(*this, write);
- BIO_meth_set_read(*this, read);
- BIO_meth_set_puts(*this, puts);
- BIO_meth_set_gets(*this, gets);
- BIO_meth_set_ctrl(*this, ctrl);
- BIO_meth_set_create(*this, create);
- BIO_meth_set_destroy(*this, destroy);
- BIO_meth_set_callback_ctrl(*this, callbackCtrl);
- }
-
-} // namespace NOpenSSL
+ BIO_meth_set_read(*this, read);
+ BIO_meth_set_puts(*this, puts);
+ BIO_meth_set_gets(*this, gets);
+ BIO_meth_set_ctrl(*this, ctrl);
+ BIO_meth_set_create(*this, create);
+ BIO_meth_set_destroy(*this, destroy);
+ BIO_meth_set_callback_ctrl(*this, callbackCtrl);
+ }
+
+} // namespace NOpenSSL
diff --git a/library/cpp/openssl/holders/bio.h b/library/cpp/openssl/holders/bio.h
index bcd6a7a9d6..2f0b71531f 100644
--- a/library/cpp/openssl/holders/bio.h
+++ b/library/cpp/openssl/holders/bio.h
@@ -1,25 +1,25 @@
-#pragma once
-
-#include <contrib/libs/openssl/include/openssl/bio.h>
-
+#pragma once
+
+#include <contrib/libs/openssl/include/openssl/bio.h>
+
#include <library/cpp/openssl/holders/holder.h>
-
-namespace NOpenSSL {
-
-class TBioMethod : public THolder<BIO_METHOD, BIO_meth_new, BIO_meth_free, int, const char*> {
-public:
- TBioMethod(
- int type,
- const char* name,
- int (*write)(BIO*, const char*, int),
- int (*read)(BIO*, char*, int),
- int (*puts)(BIO*, const char*),
- int (*gets)(BIO*, char*, int),
- long (*ctrl)(BIO*, int, long, void*),
- int (*create)(BIO*),
- int (*destroy)(BIO*),
- long (*callbackCtrl)(BIO*, int, bio_info_cb*)
- );
-};
-
-} // namespace NOpenSSL
+
+namespace NOpenSSL {
+
+class TBioMethod : public THolder<BIO_METHOD, BIO_meth_new, BIO_meth_free, int, const char*> {
+public:
+ TBioMethod(
+ int type,
+ const char* name,
+ int (*write)(BIO*, const char*, int),
+ int (*read)(BIO*, char*, int),
+ int (*puts)(BIO*, const char*),
+ int (*gets)(BIO*, char*, int),
+ long (*ctrl)(BIO*, int, long, void*),
+ int (*create)(BIO*),
+ int (*destroy)(BIO*),
+ long (*callbackCtrl)(BIO*, int, bio_info_cb*)
+ );
+};
+
+} // namespace NOpenSSL
diff --git a/library/cpp/openssl/holders/bn.h b/library/cpp/openssl/holders/bn.h
index 9d133d4bdd..a1a5eb3435 100644
--- a/library/cpp/openssl/holders/bn.h
+++ b/library/cpp/openssl/holders/bn.h
@@ -1,13 +1,13 @@
-#pragma once
-
-#include "holder.h"
-
-#include <contrib/libs/openssl/include/openssl/bn.h>
-
-namespace NOpenSSL {
- class TBignum : public THolder<BIGNUM, BN_new, BN_clear_free> {
- };
-
- class TBnCtx : public THolder<BN_CTX, BN_CTX_new, BN_CTX_free> {
- };
-}
+#pragma once
+
+#include "holder.h"
+
+#include <contrib/libs/openssl/include/openssl/bn.h>
+
+namespace NOpenSSL {
+ class TBignum : public THolder<BIGNUM, BN_new, BN_clear_free> {
+ };
+
+ class TBnCtx : public THolder<BN_CTX, BN_CTX_new, BN_CTX_free> {
+ };
+}
diff --git a/library/cpp/openssl/holders/evp.h b/library/cpp/openssl/holders/evp.h
index df3cc4c2fa..43240c1640 100644
--- a/library/cpp/openssl/holders/evp.h
+++ b/library/cpp/openssl/holders/evp.h
@@ -1,13 +1,13 @@
-#pragma once
-
-#include "holder.h"
-
-#include <contrib/libs/openssl/include/openssl/evp.h>
-
-namespace NOpenSSL {
- class TEvpCipherCtx : public THolder<EVP_CIPHER_CTX, EVP_CIPHER_CTX_new, EVP_CIPHER_CTX_free> {
- };
-
- class TEvpMdCtx : public THolder<EVP_MD_CTX, EVP_MD_CTX_new, EVP_MD_CTX_free> {
- };
-}
+#pragma once
+
+#include "holder.h"
+
+#include <contrib/libs/openssl/include/openssl/evp.h>
+
+namespace NOpenSSL {
+ class TEvpCipherCtx : public THolder<EVP_CIPHER_CTX, EVP_CIPHER_CTX_new, EVP_CIPHER_CTX_free> {
+ };
+
+ class TEvpMdCtx : public THolder<EVP_MD_CTX, EVP_MD_CTX_new, EVP_MD_CTX_free> {
+ };
+}
diff --git a/library/cpp/openssl/holders/hmac.h b/library/cpp/openssl/holders/hmac.h
index 4110e06f00..3aa820a569 100644
--- a/library/cpp/openssl/holders/hmac.h
+++ b/library/cpp/openssl/holders/hmac.h
@@ -1,10 +1,10 @@
-#pragma once
-
-#include "holder.h"
-
-#include <contrib/libs/openssl/include/openssl/hmac.h>
-
-namespace NOpenSSL {
- class THmacCtx : public THolder<HMAC_CTX, HMAC_CTX_new, HMAC_CTX_free> {
- };
-}
+#pragma once
+
+#include "holder.h"
+
+#include <contrib/libs/openssl/include/openssl/hmac.h>
+
+namespace NOpenSSL {
+ class THmacCtx : public THolder<HMAC_CTX, HMAC_CTX_new, HMAC_CTX_free> {
+ };
+}
diff --git a/library/cpp/openssl/holders/holder.h b/library/cpp/openssl/holders/holder.h
index c2a26ce431..f6049ebd02 100644
--- a/library/cpp/openssl/holders/holder.h
+++ b/library/cpp/openssl/holders/holder.h
@@ -1,32 +1,32 @@
-#pragma once
-
-#include <util/generic/yexception.h>
-
-namespace NOpenSSL {
-
-template <typename TType, auto Create, auto Destroy, class... Args>
-class THolder {
-public:
- inline THolder(Args... args) {
- Ptr = Create(args...);
- if (!Ptr) {
+#pragma once
+
+#include <util/generic/yexception.h>
+
+namespace NOpenSSL {
+
+template <typename TType, auto Create, auto Destroy, class... Args>
+class THolder {
+public:
+ inline THolder(Args... args) {
+ Ptr = Create(args...);
+ if (!Ptr) {
throw std::bad_alloc();
- }
- }
-
- THolder(const THolder&) = delete;
- THolder& operator=(const THolder&) = delete;
-
- inline ~THolder() noexcept {
- Destroy(Ptr);
- }
-
- inline operator TType* () noexcept {
- return Ptr;
- }
-
-private:
- TType* Ptr;
-};
-
-}
+ }
+ }
+
+ THolder(const THolder&) = delete;
+ THolder& operator=(const THolder&) = delete;
+
+ inline ~THolder() noexcept {
+ Destroy(Ptr);
+ }
+
+ inline operator TType* () noexcept {
+ return Ptr;
+ }
+
+private:
+ TType* Ptr;
+};
+
+}
diff --git a/library/cpp/openssl/holders/ut/evp_ut.cpp b/library/cpp/openssl/holders/ut/evp_ut.cpp
index 0f8c0aed01..7aeec7594c 100644
--- a/library/cpp/openssl/holders/ut/evp_ut.cpp
+++ b/library/cpp/openssl/holders/ut/evp_ut.cpp
@@ -1,15 +1,15 @@
-#include "evp.h"
-
+#include "evp.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-Y_UNIT_TEST_SUITE(Evp) {
- Y_UNIT_TEST(Cipher) {
- NOpenSSL::TEvpCipherCtx ctx;
- UNIT_ASSERT(ctx);
- }
-
- Y_UNIT_TEST(Md) {
- NOpenSSL::TEvpMdCtx ctx;
- UNIT_ASSERT(ctx);
- }
-}
+
+Y_UNIT_TEST_SUITE(Evp) {
+ Y_UNIT_TEST(Cipher) {
+ NOpenSSL::TEvpCipherCtx ctx;
+ UNIT_ASSERT(ctx);
+ }
+
+ Y_UNIT_TEST(Md) {
+ NOpenSSL::TEvpMdCtx ctx;
+ UNIT_ASSERT(ctx);
+ }
+}
diff --git a/library/cpp/openssl/holders/ut/hmac_ut.cpp b/library/cpp/openssl/holders/ut/hmac_ut.cpp
index 60f561c337..d241bfbe1f 100644
--- a/library/cpp/openssl/holders/ut/hmac_ut.cpp
+++ b/library/cpp/openssl/holders/ut/hmac_ut.cpp
@@ -1,10 +1,10 @@
-#include "hmac.h"
-
+#include "hmac.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-Y_UNIT_TEST_SUITE(Hmac) {
- Y_UNIT_TEST(Ctx) {
- NOpenSSL::THmacCtx ctx;
- UNIT_ASSERT(ctx);
- }
-}
+
+Y_UNIT_TEST_SUITE(Hmac) {
+ Y_UNIT_TEST(Ctx) {
+ NOpenSSL::THmacCtx ctx;
+ UNIT_ASSERT(ctx);
+ }
+}
diff --git a/library/cpp/openssl/holders/ut/ya.make b/library/cpp/openssl/holders/ut/ya.make
index 045cdc3566..7c6f550d14 100644
--- a/library/cpp/openssl/holders/ut/ya.make
+++ b/library/cpp/openssl/holders/ut/ya.make
@@ -1,10 +1,10 @@
UNITTEST_FOR(library/cpp/openssl/holders)
-
-OWNER(somov deshevoy)
-
-SRCS(
- evp_ut.cpp
- hmac_ut.cpp
-)
-
-END()
+
+OWNER(somov deshevoy)
+
+SRCS(
+ evp_ut.cpp
+ hmac_ut.cpp
+)
+
+END()
diff --git a/library/cpp/openssl/holders/x509_vfy.cpp b/library/cpp/openssl/holders/x509_vfy.cpp
index 731baa9055..dccd22fbf9 100644
--- a/library/cpp/openssl/holders/x509_vfy.cpp
+++ b/library/cpp/openssl/holders/x509_vfy.cpp
@@ -1,30 +1,30 @@
-#include "x509_vfy.h"
-
-namespace NOpenSSL {
-
- TX509LookupMethod::TX509LookupMethod(
- const char* name,
- int (*newItem) (X509_LOOKUP *ctx),
- void (*free) (X509_LOOKUP *ctx),
- int (*init) (X509_LOOKUP *ctx),
- int (*shutdown) (X509_LOOKUP *ctx),
- X509_LOOKUP_ctrl_fn ctrl,
- X509_LOOKUP_get_by_subject_fn getBySubject,
- X509_LOOKUP_get_by_issuer_serial_fn getByIssuerSerial,
- X509_LOOKUP_get_by_fingerprint_fn getByFingerprint,
- X509_LOOKUP_get_by_alias_fn getByAlias
- )
- : THolder(name)
- {
- X509_LOOKUP_meth_set_new_item(*this, newItem);
- X509_LOOKUP_meth_set_free(*this, free);
- X509_LOOKUP_meth_set_init(*this, init);
- X509_LOOKUP_meth_set_shutdown(*this, shutdown);
- X509_LOOKUP_meth_set_ctrl(*this, ctrl);
- X509_LOOKUP_meth_set_get_by_subject(*this, getBySubject);
- X509_LOOKUP_meth_set_get_by_issuer_serial(*this, getByIssuerSerial);
- X509_LOOKUP_meth_set_get_by_fingerprint(*this, getByFingerprint);
- X509_LOOKUP_meth_set_get_by_alias(*this, getByAlias);
- }
-
-} // namespace NOpenSSL
+#include "x509_vfy.h"
+
+namespace NOpenSSL {
+
+ TX509LookupMethod::TX509LookupMethod(
+ const char* name,
+ int (*newItem) (X509_LOOKUP *ctx),
+ void (*free) (X509_LOOKUP *ctx),
+ int (*init) (X509_LOOKUP *ctx),
+ int (*shutdown) (X509_LOOKUP *ctx),
+ X509_LOOKUP_ctrl_fn ctrl,
+ X509_LOOKUP_get_by_subject_fn getBySubject,
+ X509_LOOKUP_get_by_issuer_serial_fn getByIssuerSerial,
+ X509_LOOKUP_get_by_fingerprint_fn getByFingerprint,
+ X509_LOOKUP_get_by_alias_fn getByAlias
+ )
+ : THolder(name)
+ {
+ X509_LOOKUP_meth_set_new_item(*this, newItem);
+ X509_LOOKUP_meth_set_free(*this, free);
+ X509_LOOKUP_meth_set_init(*this, init);
+ X509_LOOKUP_meth_set_shutdown(*this, shutdown);
+ X509_LOOKUP_meth_set_ctrl(*this, ctrl);
+ X509_LOOKUP_meth_set_get_by_subject(*this, getBySubject);
+ X509_LOOKUP_meth_set_get_by_issuer_serial(*this, getByIssuerSerial);
+ X509_LOOKUP_meth_set_get_by_fingerprint(*this, getByFingerprint);
+ X509_LOOKUP_meth_set_get_by_alias(*this, getByAlias);
+ }
+
+} // namespace NOpenSSL
diff --git a/library/cpp/openssl/holders/x509_vfy.h b/library/cpp/openssl/holders/x509_vfy.h
index b735d8a042..1e186d0865 100644
--- a/library/cpp/openssl/holders/x509_vfy.h
+++ b/library/cpp/openssl/holders/x509_vfy.h
@@ -1,25 +1,25 @@
-#pragma once
-
-#include <contrib/libs/openssl/include/openssl/x509_vfy.h>
-
+#pragma once
+
+#include <contrib/libs/openssl/include/openssl/x509_vfy.h>
+
#include <library/cpp/openssl/holders/holder.h>
-
-namespace NOpenSSL {
-
-class TX509LookupMethod : public THolder<X509_LOOKUP_METHOD, X509_LOOKUP_meth_new, X509_LOOKUP_meth_free, const char*> {
-public:
- TX509LookupMethod(
- const char* name,
- int (*newItem) (X509_LOOKUP *ctx),
- void (*free) (X509_LOOKUP *ctx),
- int (*init) (X509_LOOKUP *ctx),
- int (*shutdown) (X509_LOOKUP *ctx),
- X509_LOOKUP_ctrl_fn ctrl,
- X509_LOOKUP_get_by_subject_fn getBySubject,
- X509_LOOKUP_get_by_issuer_serial_fn getByIssuerSerial,
- X509_LOOKUP_get_by_fingerprint_fn getByFingerprint,
- X509_LOOKUP_get_by_alias_fn getByAlias
- );
-};
-
-} // namespace NOpenSSL
+
+namespace NOpenSSL {
+
+class TX509LookupMethod : public THolder<X509_LOOKUP_METHOD, X509_LOOKUP_meth_new, X509_LOOKUP_meth_free, const char*> {
+public:
+ TX509LookupMethod(
+ const char* name,
+ int (*newItem) (X509_LOOKUP *ctx),
+ void (*free) (X509_LOOKUP *ctx),
+ int (*init) (X509_LOOKUP *ctx),
+ int (*shutdown) (X509_LOOKUP *ctx),
+ X509_LOOKUP_ctrl_fn ctrl,
+ X509_LOOKUP_get_by_subject_fn getBySubject,
+ X509_LOOKUP_get_by_issuer_serial_fn getByIssuerSerial,
+ X509_LOOKUP_get_by_fingerprint_fn getByFingerprint,
+ X509_LOOKUP_get_by_alias_fn getByAlias
+ );
+};
+
+} // namespace NOpenSSL
diff --git a/library/cpp/openssl/holders/ya.make b/library/cpp/openssl/holders/ya.make
index 3a2fbf3ba5..ca5caecb62 100644
--- a/library/cpp/openssl/holders/ya.make
+++ b/library/cpp/openssl/holders/ya.make
@@ -1,16 +1,16 @@
-LIBRARY()
-
-OWNER(somov deshevoy)
-
-PEERDIR(
- contrib/libs/openssl
-)
-
-SRCS(
- bio.cpp
- x509_vfy.cpp
-)
-
-END()
-
-NEED_CHECK()
+LIBRARY()
+
+OWNER(somov deshevoy)
+
+PEERDIR(
+ contrib/libs/openssl
+)
+
+SRCS(
+ bio.cpp
+ x509_vfy.cpp
+)
+
+END()
+
+NEED_CHECK()
diff --git a/library/cpp/openssl/init/init.cpp b/library/cpp/openssl/init/init.cpp
index ae68ef08ea..b136e1f032 100644
--- a/library/cpp/openssl/init/init.cpp
+++ b/library/cpp/openssl/init/init.cpp
@@ -44,11 +44,11 @@ namespace {
};
inline TInitSsl() {
- OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, nullptr);
+ OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, nullptr);
}
inline ~TInitSsl() {
- OPENSSL_cleanup();
+ OPENSSL_cleanup();
}
static void LockingFunction(int mode, int n, const char* /*file*/, int /*line*/) {
@@ -62,5 +62,5 @@ namespace {
}
void InitOpenSSL() {
- (void)SingletonWithPriority<TInitSsl, 0>();
+ (void)SingletonWithPriority<TInitSsl, 0>();
}
diff --git a/library/cpp/openssl/io/stream.cpp b/library/cpp/openssl/io/stream.cpp
index 0b4be38c0e..191e5422f7 100644
--- a/library/cpp/openssl/io/stream.cpp
+++ b/library/cpp/openssl/io/stream.cpp
@@ -84,47 +84,47 @@ namespace {
return ctx;
}
- struct TStreamIO : public NOpenSSL::TAbstractIO {
- inline TStreamIO(IInputStream* in, IOutputStream* out)
- : In(in)
- , Out(out)
- {
- }
-
- int Write(const char* data, size_t dlen, size_t* written) override {
- Out->Write(data, dlen);
-
- *written = dlen;
- return 1;
+ struct TStreamIO : public NOpenSSL::TAbstractIO {
+ inline TStreamIO(IInputStream* in, IOutputStream* out)
+ : In(in)
+ , Out(out)
+ {
+ }
+
+ int Write(const char* data, size_t dlen, size_t* written) override {
+ Out->Write(data, dlen);
+
+ *written = dlen;
+ return 1;
}
- int Read(char* data, size_t dlen, size_t* readbytes) override {
- *readbytes = In->Read(data, dlen);
- return 1;
+ int Read(char* data, size_t dlen, size_t* readbytes) override {
+ *readbytes = In->Read(data, dlen);
+ return 1;
}
- int Puts(const char* buf) override {
- Y_UNUSED(buf);
- return -1;
+ int Puts(const char* buf) override {
+ Y_UNUSED(buf);
+ return -1;
}
- int Gets(char* buf, int size) override {
- Y_UNUSED(buf);
- Y_UNUSED(size);
- return -1;
+ int Gets(char* buf, int size) override {
+ Y_UNUSED(buf);
+ Y_UNUSED(size);
+ return -1;
}
- void Flush() override {
+ void Flush() override {
}
- IInputStream* In;
- IOutputStream* Out;
+ IInputStream* In;
+ IOutputStream* Out;
};
struct TSslIO: public TSslInitOnDemand, public TOptions {
inline TSslIO(IInputStream* in, IOutputStream* out, const TOptions& opts)
: TOptions(opts)
- , Io(in, out)
+ , Io(in, out)
, Ctx(CreateClientContext())
, Ssl(ConstructSsl())
{
@@ -175,8 +175,8 @@ namespace {
InitVerification(ssl.Get());
}
- BIO_up_ref(Io); // SSL_set_bio consumes only one reference if rbio and wbio are the same
- SSL_set_bio(ssl.Get(), Io, Io);
+ BIO_up_ref(Io); // SSL_set_bio consumes only one reference if rbio and wbio are the same
+ SSL_set_bio(ssl.Get(), Io, Io);
return ssl;
}
@@ -233,7 +233,7 @@ namespace {
}
}
- TStreamIO Io;
+ TStreamIO Io;
TSslContextPtr Ctx;
TSslPtr Ssl;
};
diff --git a/library/cpp/openssl/method/io.cpp b/library/cpp/openssl/method/io.cpp
index d184b6456c..bafa974b8a 100644
--- a/library/cpp/openssl/method/io.cpp
+++ b/library/cpp/openssl/method/io.cpp
@@ -1,122 +1,122 @@
-#include "io.h"
-
-#include <util/generic/singleton.h>
-#include <util/generic/yexception.h>
-#include <util/system/compiler.h>
-#include <util/system/yassert.h>
-
-namespace {
- using NOpenSSL::TAbstractIO;
-
- TAbstractIO* IO(BIO* bio) noexcept {
- void* ptr = BIO_get_data(bio);
- Y_VERIFY(ptr);
- return static_cast<TAbstractIO*>(ptr);
- }
-
- template<class T, class Callable, class... Args>
- T ExceptionBoundary(BIO* bio, Callable&& f, T err, Args&&... args) noexcept {
- try {
- return (IO(bio)->*f)(args...);
- } catch (...) {
- return err;
- }
- }
-
- int Write(BIO* bio, const char* data, int dlen) noexcept {
- return ExceptionBoundary(bio, &TAbstractIO::WriteOld, -1, data, dlen);
- }
-
- int Read(BIO* bio, char* data, int dlen) noexcept {
- return ExceptionBoundary(bio, &TAbstractIO::ReadOld, -1, data, dlen);
- }
-
- int Puts(BIO* bio, const char* buf) noexcept {
- return ExceptionBoundary(bio, &TAbstractIO::Puts, -1, buf);
- }
-
- int Gets(BIO* bio, char* buf, int size) noexcept {
- return ExceptionBoundary(bio, &TAbstractIO::Gets, -1, buf, size);
- }
-
- long Ctrl(BIO* bio, int cmd, long larg, void* parg) noexcept {
- return ExceptionBoundary(bio, &TAbstractIO::Ctrl, -1, cmd, larg, parg);
- }
-
- int Create(BIO* bio) noexcept {
- BIO_set_data(bio, nullptr);
- BIO_set_init(bio, 1);
- return 1;
- }
-
- int Destroy(BIO* bio) noexcept {
- BIO_set_data(bio, nullptr);
- BIO_set_init(bio, 0);
- return 1;
- }
-
- NOpenSSL::TBioMethod* Method() {
- return SingletonWithPriority<NOpenSSL::TBioMethod, 32768>(
- BIO_get_new_index() | BIO_TYPE_SOURCE_SINK,
- "AbstractIO",
- Write,
- Read,
- Puts,
- Gets,
- Ctrl,
- Create,
- Destroy,
- nullptr
- );
- }
-}
-
-namespace NOpenSSL {
-
- TAbstractIO::TAbstractIO()
- : Bio(BIO_new(*Method())) {
- if (Y_UNLIKELY(!Bio)) {
+#include "io.h"
+
+#include <util/generic/singleton.h>
+#include <util/generic/yexception.h>
+#include <util/system/compiler.h>
+#include <util/system/yassert.h>
+
+namespace {
+ using NOpenSSL::TAbstractIO;
+
+ TAbstractIO* IO(BIO* bio) noexcept {
+ void* ptr = BIO_get_data(bio);
+ Y_VERIFY(ptr);
+ return static_cast<TAbstractIO*>(ptr);
+ }
+
+ template<class T, class Callable, class... Args>
+ T ExceptionBoundary(BIO* bio, Callable&& f, T err, Args&&... args) noexcept {
+ try {
+ return (IO(bio)->*f)(args...);
+ } catch (...) {
+ return err;
+ }
+ }
+
+ int Write(BIO* bio, const char* data, int dlen) noexcept {
+ return ExceptionBoundary(bio, &TAbstractIO::WriteOld, -1, data, dlen);
+ }
+
+ int Read(BIO* bio, char* data, int dlen) noexcept {
+ return ExceptionBoundary(bio, &TAbstractIO::ReadOld, -1, data, dlen);
+ }
+
+ int Puts(BIO* bio, const char* buf) noexcept {
+ return ExceptionBoundary(bio, &TAbstractIO::Puts, -1, buf);
+ }
+
+ int Gets(BIO* bio, char* buf, int size) noexcept {
+ return ExceptionBoundary(bio, &TAbstractIO::Gets, -1, buf, size);
+ }
+
+ long Ctrl(BIO* bio, int cmd, long larg, void* parg) noexcept {
+ return ExceptionBoundary(bio, &TAbstractIO::Ctrl, -1, cmd, larg, parg);
+ }
+
+ int Create(BIO* bio) noexcept {
+ BIO_set_data(bio, nullptr);
+ BIO_set_init(bio, 1);
+ return 1;
+ }
+
+ int Destroy(BIO* bio) noexcept {
+ BIO_set_data(bio, nullptr);
+ BIO_set_init(bio, 0);
+ return 1;
+ }
+
+ NOpenSSL::TBioMethod* Method() {
+ return SingletonWithPriority<NOpenSSL::TBioMethod, 32768>(
+ BIO_get_new_index() | BIO_TYPE_SOURCE_SINK,
+ "AbstractIO",
+ Write,
+ Read,
+ Puts,
+ Gets,
+ Ctrl,
+ Create,
+ Destroy,
+ nullptr
+ );
+ }
+}
+
+namespace NOpenSSL {
+
+ TAbstractIO::TAbstractIO()
+ : Bio(BIO_new(*Method())) {
+ if (Y_UNLIKELY(!Bio)) {
throw std::bad_alloc();
- }
- BIO_set_data(Bio, this);
- }
-
- TAbstractIO::~TAbstractIO() {
- BIO_free(Bio);
- }
-
- int TAbstractIO::WriteOld(const char* data, int dlen) {
- size_t written = 0;
-
- int ret = Write(data, dlen, &written);
- if (ret <= 0) {
- return ret;
- }
-
- return written;
- }
-
- int TAbstractIO::ReadOld(char* data, int dlen) {
- size_t readbytes = 0;
-
- int ret = Read(data, dlen, &readbytes);
- if (ret <= 0) {
- return ret;
- }
-
- return readbytes;
- }
-
- long TAbstractIO::Ctrl(int cmd, long larg, void* parg) {
- Y_UNUSED(larg);
- Y_UNUSED(parg);
-
- if (cmd == BIO_CTRL_FLUSH) {
- Flush();
- return 1;
- }
-
- return 0;
- }
-
-} // namespace NOpenSSL
+ }
+ BIO_set_data(Bio, this);
+ }
+
+ TAbstractIO::~TAbstractIO() {
+ BIO_free(Bio);
+ }
+
+ int TAbstractIO::WriteOld(const char* data, int dlen) {
+ size_t written = 0;
+
+ int ret = Write(data, dlen, &written);
+ if (ret <= 0) {
+ return ret;
+ }
+
+ return written;
+ }
+
+ int TAbstractIO::ReadOld(char* data, int dlen) {
+ size_t readbytes = 0;
+
+ int ret = Read(data, dlen, &readbytes);
+ if (ret <= 0) {
+ return ret;
+ }
+
+ return readbytes;
+ }
+
+ long TAbstractIO::Ctrl(int cmd, long larg, void* parg) {
+ Y_UNUSED(larg);
+ Y_UNUSED(parg);
+
+ if (cmd == BIO_CTRL_FLUSH) {
+ Flush();
+ return 1;
+ }
+
+ return 0;
+ }
+
+} // namespace NOpenSSL
diff --git a/library/cpp/openssl/method/io.h b/library/cpp/openssl/method/io.h
index f1d3df978d..ffe1da62f3 100644
--- a/library/cpp/openssl/method/io.h
+++ b/library/cpp/openssl/method/io.h
@@ -1,31 +1,31 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/openssl/holders/bio.h>
-
-namespace NOpenSSL {
-
-class TAbstractIO {
-public:
- TAbstractIO();
- virtual ~TAbstractIO();
-
- virtual int Write(const char* data, size_t dlen, size_t* written) = 0;
- virtual int Read(char* data, size_t dlen, size_t* readbytes) = 0;
- virtual int Puts(const char* buf) = 0;
- virtual int Gets(char* buf, int size) = 0;
-
- virtual long Ctrl(int cmd, long larg, void* parg);
- virtual void Flush() = 0;
-
- int WriteOld(const char* data, int dlen);
- int ReadOld(char* data, int dlen);
-
- inline operator BIO* () noexcept {
- return Bio;
- }
-
-private:
- BIO* Bio;
-};
-
-} // namespace NOpenSSL
+
+namespace NOpenSSL {
+
+class TAbstractIO {
+public:
+ TAbstractIO();
+ virtual ~TAbstractIO();
+
+ virtual int Write(const char* data, size_t dlen, size_t* written) = 0;
+ virtual int Read(char* data, size_t dlen, size_t* readbytes) = 0;
+ virtual int Puts(const char* buf) = 0;
+ virtual int Gets(char* buf, int size) = 0;
+
+ virtual long Ctrl(int cmd, long larg, void* parg);
+ virtual void Flush() = 0;
+
+ int WriteOld(const char* data, int dlen);
+ int ReadOld(char* data, int dlen);
+
+ inline operator BIO* () noexcept {
+ return Bio;
+ }
+
+private:
+ BIO* Bio;
+};
+
+} // namespace NOpenSSL
diff --git a/library/cpp/openssl/method/ut/io_ut.cpp b/library/cpp/openssl/method/ut/io_ut.cpp
index bff2b23d31..ec6f6c6396 100644
--- a/library/cpp/openssl/method/ut/io_ut.cpp
+++ b/library/cpp/openssl/method/ut/io_ut.cpp
@@ -1,52 +1,52 @@
#include <library/cpp/openssl/method/io.h>
-
+
#include <library/cpp/testing/unittest/registar.h>
-
-class TTestIO : public NOpenSSL::TAbstractIO {
-public:
- int Write(const char* data, size_t dlen, size_t* written) override {
- Y_UNUSED(data);
- *written = dlen;
- return 1;
- }
-
- int Read(char* data, size_t dlen, size_t* readbytes) override {
- Y_UNUSED(data);
- Y_UNUSED(dlen);
- *readbytes = 0;
- return 0;
- }
-
- int Puts(const char* buf) override {
- if (buf == nullptr) {
- return 0;
- }
-
- return strlen(buf);
- }
-
- int Gets(char* buf, int size) override {
- Y_UNUSED(buf);
- Y_UNUSED(size);
- return 0;
- }
-
- void Flush() override {
-
- }
-};
-
-Y_UNIT_TEST_SUITE(IO) {
- Y_UNIT_TEST(AbstractIO) {
- static const char s[] = "12345";
-
- TTestIO test;
-
- UNIT_ASSERT(BIO_write(test, s, sizeof(s)) == sizeof(s));
- UNIT_ASSERT(BIO_puts(test, s) == strlen(s));
-
- char buf[128];
- UNIT_ASSERT(BIO_read(test, buf, sizeof(buf)) == 0);
- UNIT_ASSERT(BIO_gets(test, buf, sizeof(buf)) == 0);
- }
-}
+
+class TTestIO : public NOpenSSL::TAbstractIO {
+public:
+ int Write(const char* data, size_t dlen, size_t* written) override {
+ Y_UNUSED(data);
+ *written = dlen;
+ return 1;
+ }
+
+ int Read(char* data, size_t dlen, size_t* readbytes) override {
+ Y_UNUSED(data);
+ Y_UNUSED(dlen);
+ *readbytes = 0;
+ return 0;
+ }
+
+ int Puts(const char* buf) override {
+ if (buf == nullptr) {
+ return 0;
+ }
+
+ return strlen(buf);
+ }
+
+ int Gets(char* buf, int size) override {
+ Y_UNUSED(buf);
+ Y_UNUSED(size);
+ return 0;
+ }
+
+ void Flush() override {
+
+ }
+};
+
+Y_UNIT_TEST_SUITE(IO) {
+ Y_UNIT_TEST(AbstractIO) {
+ static const char s[] = "12345";
+
+ TTestIO test;
+
+ UNIT_ASSERT(BIO_write(test, s, sizeof(s)) == sizeof(s));
+ UNIT_ASSERT(BIO_puts(test, s) == strlen(s));
+
+ char buf[128];
+ UNIT_ASSERT(BIO_read(test, buf, sizeof(buf)) == 0);
+ UNIT_ASSERT(BIO_gets(test, buf, sizeof(buf)) == 0);
+ }
+}
diff --git a/library/cpp/openssl/method/ut/ya.make b/library/cpp/openssl/method/ut/ya.make
index 3645ad17e6..953c790707 100644
--- a/library/cpp/openssl/method/ut/ya.make
+++ b/library/cpp/openssl/method/ut/ya.make
@@ -1,9 +1,9 @@
UNITTEST_FOR(library/cpp/openssl/method)
-
-OWNER(somov deshevoy)
-
-SRCS(
- io_ut.cpp
-)
-
-END()
+
+OWNER(somov deshevoy)
+
+SRCS(
+ io_ut.cpp
+)
+
+END()
diff --git a/library/cpp/openssl/method/ya.make b/library/cpp/openssl/method/ya.make
index c8f6f18b6b..1fb716104f 100644
--- a/library/cpp/openssl/method/ya.make
+++ b/library/cpp/openssl/method/ya.make
@@ -1,14 +1,14 @@
-LIBRARY()
-
-OWNER(somov deshevoy)
-
-PEERDIR(
- contrib/libs/openssl
+LIBRARY()
+
+OWNER(somov deshevoy)
+
+PEERDIR(
+ contrib/libs/openssl
library/cpp/openssl/holders
-)
-
-SRCS(
- io.cpp
-)
-
-END()
+)
+
+SRCS(
+ io.cpp
+)
+
+END()
diff --git a/library/cpp/openssl/ya.make b/library/cpp/openssl/ya.make
index 7c10963e26..67c5404d59 100644
--- a/library/cpp/openssl/ya.make
+++ b/library/cpp/openssl/ya.make
@@ -3,11 +3,11 @@ RECURSE(
big_integer/ut
crypto
crypto/ut
- holders
- holders/ut
+ holders
+ holders/ut
io
io/ut
- method
- method/ut
+ method
+ method/ut
init
)