diff --git a/src/proxy/tinymitm/raai-helper.cpp b/src/proxy/tinymitm/raai-helper.cpp new file mode 100644 index 0000000..51661a6 --- /dev/null +++ b/src/proxy/tinymitm/raai-helper.cpp @@ -0,0 +1,33 @@ +#include "raai-helper.h" + +#include +#include + +#include +#include + +void WolfSSLDeleter::operator()(WC_RNG* rng) +{ + if (rng) + { + wc_FreeRng(rng); + delete r; + } +} +void WolfSSLDeleter::operator()(RsaKey* key) +{ + if (key) + { + wc_FreeRsaKey(key); + delete k; + } +} +void WolfSSLDeleter::operator()(WOLFSSL_CTX* ctx) +{ + if (ctx) wolfSSL_CTX_free(ctx); +} + +void WolfSSLDeleter::operator()(WOLFSSL* ssl) +{ + if (ssl) wolfSSL_free(ssl); +} diff --git a/src/proxy/tinymitm/raai-helper.h b/src/proxy/tinymitm/raai-helper.h new file mode 100644 index 0000000..aec8098 --- /dev/null +++ b/src/proxy/tinymitm/raai-helper.h @@ -0,0 +1,14 @@ +#pragma once + +struct WC_RNG; +struct RsaKey; +struct WOLFSSL_CTX; +struct WOLFSSL; + +struct WolfSSLDeleter +{ + void operator()(WC_RNG* rng); + void operator()(RsaKey* key); + void operator()(WOLFSSL_CTX* ctx); + void operator()(WOLFSSL* ssl); +};