4#include "Stroika/Foundation/StroikaPreComp.h"
6#if qStroika_HasComponent_OpenSSL
7#include <openssl/err.h>
8#include <openssl/evp.h>
11#include "Stroika/Foundation/Containers/Common.h"
13#include "Stroika/Foundation/Execution/Common.h"
20using namespace Stroika::Foundation::Cryptography;
21using namespace Stroika::Foundation::Cryptography::Providers::OpenSSL;
22using namespace Stroika::Foundation::Memory;
24#if qStroika_HasComponent_OpenSSL && defined(_MSC_VER)
26#if OPENSSL_VERSION_NUMBER < 0x1010000fL
27#pragma comment(lib, "libeay32.lib")
28#pragma comment(lib, "ssleay32.lib")
30#pragma comment(lib, "libcrypto.lib")
31#pragma comment(lib, "libssl.lib")
32#pragma comment(lib, "ws2_32.lib")
33#pragma comment(lib, "crypt32.lib")
39#if qStroika_HasComponent_OpenSSL
44 struct ErrStringIniter_ {
47 if (sNamesSupported_) {
48 auto l = sNamesLoaded_.
rwget ();
49 if (
static_cast<bool> (l)) {
55 } _InitOpenSSLErrStrings_;
56 void LoadStringsIfNeeded_ ()
58 if (not sNamesLoaded_ and sNamesSupported_) {
59 auto l = sNamesLoaded_.rwget ();
60 if (not
static_cast<bool> (l)) {
61 ERR_load_crypto_strings ();
73Exception::Exception (InternalErrorCodeType errorCode)
74 : inherited{GetMessage (errorCode)}
75 , fErrorCode_{errorCode}
79Exception::InternalErrorCodeType Exception::GetErrorCode ()
const
86 LoadStringsIfNeeded_ ();
89 ::ERR_error_string_n (errorCode, buf, NEltsOf (buf));
93[[noreturn]]
void Exception::ThrowLastError ()
98bool Exception::GetNamesSupported ()
100 return sNamesSupported_.load ();
103void Exception::SetNamesSupported (
bool openSSLStringsSupported)
105 auto l = sNamesSupported_.rwget ();
106 if (
static_cast<bool> (l) != openSSLStringsSupported) {
107 if (openSSLStringsSupported) {
111 auto lNamesLoaded = sNamesLoaded_.rwget ();
112 if (
static_cast<bool> (l)) {
114 lNamesLoaded =
false;
117 sNamesSupported_ = openSSLStringsSupported;
String is like std::u32string, except it is much easier to use, often much more space efficient,...
static String FromNarrowSDKString(const char *from)
Wrap any object with Synchronized<> and it can be used similarly to the base type,...
nonvirtual WritableReference rwget()
get a read-write smart pointer to the underlying Synchronized<> object, holding the full lock the who...
void Throw(T &&e2Throw)
identical to builtin C++ 'throw' except that it does helpful, type dependent DbgTrace() messages firs...