4#include "Stroika/Foundation/StroikaPreComp.h"
6#if qStroika_HasComponent_OpenSSL
7#include <openssl/evp.h>
8#include <openssl/pem.h>
9#include <openssl/ssl.h>
13#include "Stroika/Foundation/Execution/Exceptions.h"
16#include "PrivateKey.h"
20using namespace Stroika::Foundation::Cryptography;
21using namespace Stroika::Foundation::Cryptography::Providers;
22using namespace Stroika::Foundation::Cryptography::Providers::OpenSSL;
23using namespace Stroika::Foundation::Debug;
31#if qStroika_HasComponent_OpenSSL
39 b = ::BIO_new (::BIO_s_mem ());
41 BIO2String_ (
const BIO2String_&) =
delete;
45 BIO_get_mem_ptr (b, &p);
46 return String{span{p->data, p->length}};
56 struct Rep_ : OpenSSL::PrivateKey::IRep {
58 OpenSSL::PrivateKey::LibRepType fKey_;
61 Rep_ (
const Rep_&) =
delete;
62 Rep_ (Rep_&&) =
default;
63 Rep_ (OpenSSL::PrivateKey::LibRepType&& p)
67 virtual EVP_PKEY* Get_EVP_PKEY ()
const override
71 virtual int GetType ()
const override
73 return ::EVP_PKEY_get_base_id (fKey_.get ());
75 virtual unsigned int GetBits ()
const override
77 return ::EVP_PKEY_get_bits (fKey_.get ());
79 virtual String GetPrintSummary ()
const override
85 if (::EVP_PKEY_print_public (b.b, fKey_.get (), 0,
nullptr) == 1) {
91 if (::EVP_PKEY_print_private (b.b, fKey_.get (), 0,
nullptr) == 1) {
97 if (::EVP_PKEY_print_params (b.b, fKey_.get (), 0,
nullptr) == 1) {
107#if qStroika_HasComponent_OpenSSL
108auto OpenSSL::PrivateKey::New (LibRepType&& p) -> Ptr
110 return Memory::MakeSharedPtr<Rep_> (move (p));
Similar to String, but intended to more efficiently construct a String. Mutable type (String is large...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
String ToString(T &&t, ARGS... args)
Return a debug-friendly, display version of the argument: not guaranteed parsable or usable except fo...