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"
15#include "PrivateKey.h"
19using namespace Stroika::Foundation::Cryptography;
20using namespace Stroika::Foundation::Cryptography::Providers;
21using namespace Stroika::Foundation::Cryptography::Providers::OpenSSL;
22using namespace Stroika::Foundation::Debug;
30#if qStroika_HasComponent_OpenSSL
38 b = ::BIO_new (::BIO_s_mem ());
40 BIO2String_ (
const BIO2String_&) =
delete;
44 BIO_get_mem_ptr (b, &p);
45 return String{span{p->data, p->length}};
55 struct Rep_ : OpenSSL::PrivateKey::IRep {
57 OpenSSL::PrivateKey::LibRepType fKey_;
60 Rep_ (
const Rep_&) =
delete;
61 Rep_ (Rep_&&) =
default;
62 Rep_ (OpenSSL::PrivateKey::LibRepType&& p)
66 virtual EVP_PKEY* Get_EVP_PKEY ()
const override
70 virtual int GetType ()
const override
72 return ::EVP_PKEY_get_base_id (fKey_.get ());
74 virtual unsigned int GetBits ()
const override
76 return ::EVP_PKEY_get_bits (fKey_.get ());
78 virtual String GetPrintSummary ()
const override
84 if (::EVP_PKEY_print_public (b.b, fKey_.get (), 0,
nullptr) == 1) {
90 if (::EVP_PKEY_print_private (b.b, fKey_.get (), 0,
nullptr) == 1) {
96 if (::EVP_PKEY_print_params (b.b, fKey_.get (), 0,
nullptr) == 1) {
106#if qStroika_HasComponent_OpenSSL
107auto OpenSSL::PrivateKey::New (LibRepType&& p) -> Ptr
109 return make_shared<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...