feat: add WolfSSL RAAI helper functions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
};
|
||||
Reference in New Issue
Block a user