feat: add WolfSSL RAAI helper functions

This commit is contained in:
2026-05-12 16:23:42 -03:00
parent 7eac4f6a8b
commit 4d1cf70100
2 changed files with 47 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#include "raai-helper.h"
#include <wolfssl/options.h>
#include <wolfssl/ssl.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/rsa.h>
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);
}
+14
View File
@@ -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);
};