|
@@ -6964,6 +6964,28 @@ static int ReuseKey(WOLFSSL* ssl, int type, void* pKey)
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#ifdef WOLFSSL_ASYNC_IO
|
|
|
+void FreeAsyncCtx(WOLFSSL* ssl, byte freeAsync)
|
|
|
+{
|
|
|
+ if (ssl->async != NULL) {
|
|
|
+ if (ssl->async->freeArgs != NULL) {
|
|
|
+ ssl->async->freeArgs(ssl, ssl->async->args);
|
|
|
+ ssl->async->freeArgs = NULL;
|
|
|
+ }
|
|
|
+#if defined(WOLFSSL_ASYNC_CRYPT) && !defined(WOLFSSL_NO_TLS12)
|
|
|
+ if (ssl->options.buildArgsSet) {
|
|
|
+ FreeBuildMsgArgs(ssl, &ssl->async->buildArgs);
|
|
|
+ ssl->options.buildArgsSet = 0;
|
|
|
+ }
|
|
|
+#endif
|
|
|
+ if (freeAsync) {
|
|
|
+ XFREE(ssl->async, ssl->heap, DYNAMIC_TYPE_ASYNC);
|
|
|
+ ssl->async = NULL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
void FreeKeyExchange(WOLFSSL* ssl)
|
|
|
{
|
|
|
/* Cleanup signature buffer */
|
|
@@ -6986,17 +7008,6 @@ void FreeKeyExchange(WOLFSSL* ssl)
|
|
|
#ifndef NO_DH
|
|
|
/* Free temp DH key */
|
|
|
FreeKey(ssl, DYNAMIC_TYPE_DH, (void**)&ssl->buffers.serverDH_Key);
|
|
|
-#endif
|
|
|
-
|
|
|
- /* Cleanup async */
|
|
|
-#ifdef WOLFSSL_ASYNC_IO
|
|
|
- if (ssl->async.freeArgs) {
|
|
|
- ssl->async.freeArgs(ssl, ssl->async.args);
|
|
|
- ssl->async.freeArgs = NULL;
|
|
|
- }
|
|
|
-#if defined(WOLFSSL_ASYNC_CRYPT) && !defined(WOLFSSL_NO_TLS12)
|
|
|
- FreeBuildMsgArgs(ssl, &ssl->async.buildArgs);
|
|
|
-#endif
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -7044,6 +7055,10 @@ void SSL_ResourceFree(WOLFSSL* ssl)
|
|
|
FreeCiphers(ssl);
|
|
|
FreeArrays(ssl, 0);
|
|
|
FreeKeyExchange(ssl);
|
|
|
+#ifdef WOLFSSL_ASYNC_IO
|
|
|
+ /* Cleanup async */
|
|
|
+ FreeAsyncCtx(ssl, 1);
|
|
|
+#endif
|
|
|
if (ssl->options.weOwnRng) {
|
|
|
wc_FreeRng(ssl->rng);
|
|
|
XFREE(ssl->rng, ssl->heap, DYNAMIC_TYPE_RNG);
|
|
@@ -11984,8 +11999,8 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|
|
{
|
|
|
int ret = 0;
|
|
|
#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_NONBLOCK_OCSP)
|
|
|
- ProcPeerCertArgs* args = (ProcPeerCertArgs*)ssl->async.args;
|
|
|
- WOLFSSL_ASSERT_SIZEOF_GE(ssl->async.args, *args);
|
|
|
+ ProcPeerCertArgs* args = NULL;
|
|
|
+ WOLFSSL_ASSERT_SIZEOF_GE(ssl->async->args, *args);
|
|
|
#elif defined(WOLFSSL_SMALL_STACK)
|
|
|
ProcPeerCertArgs* args = NULL;
|
|
|
#else
|
|
@@ -11996,7 +12011,15 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|
|
|
|
|
WOLFSSL_ENTER("ProcessPeerCerts");
|
|
|
|
|
|
-#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_ASYNC_CRYPT)
|
|
|
+#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_NONBLOCK_OCSP)
|
|
|
+ if (ssl->async == NULL) {
|
|
|
+ ssl->async = (struct WOLFSSL_ASYNC*)
|
|
|
+ XMALLOC(sizeof(struct WOLFSSL_ASYNC), ssl->heap,
|
|
|
+ DYNAMIC_TYPE_ASYNC);
|
|
|
+ if (ssl->async == NULL)
|
|
|
+ ERROR_OUT(MEMORY_E, exit_ppc);
|
|
|
+ }
|
|
|
+ args = (ProcPeerCertArgs*)ssl->async->args;
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
ret = wolfSSL_AsyncPop(ssl, &ssl->options.asyncState);
|
|
|
if (ret != WC_NOT_PENDING_E) {
|
|
@@ -12027,7 +12050,7 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|
|
args->idx = *inOutIdx;
|
|
|
args->begin = *inOutIdx;
|
|
|
#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_NONBLOCK_OCSP)
|
|
|
- ssl->async.freeArgs = FreeProcPeerCertArgs;
|
|
|
+ ssl->async->freeArgs = FreeProcPeerCertArgs;
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -13344,8 +13367,10 @@ exit_ppc:
|
|
|
}
|
|
|
#endif /* WOLFSSL_ASYNC_CRYPT || WOLFSSL_NONBLOCK_OCSP */
|
|
|
|
|
|
-#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_NONBLOCK_OCSP) || \
|
|
|
- defined(WOLFSSL_SMALL_STACK)
|
|
|
+#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_NONBLOCK_OCSP)
|
|
|
+ /* Cleanup async */
|
|
|
+ FreeAsyncCtx(ssl, 0);
|
|
|
+#elif defined(WOLFSSL_SMALL_STACK)
|
|
|
if (args)
|
|
|
{
|
|
|
FreeProcPeerCertArgs(ssl, args);
|
|
@@ -18508,13 +18533,19 @@ int BuildCertHashes(WOLFSSL* ssl, Hashes* hashes)
|
|
|
#ifndef WOLFSSL_NO_TLS12
|
|
|
void FreeBuildMsgArgs(WOLFSSL* ssl, BuildMsgArgs* args)
|
|
|
{
|
|
|
- if (args) {
|
|
|
+ if (args
|
|
|
+#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ && ssl->options.buildArgsSet
|
|
|
+#endif
|
|
|
+ ) {
|
|
|
/* only free the IV if it was dynamically allocated */
|
|
|
if (ssl && args->iv && (args->iv != args->staticIvBuffer)) {
|
|
|
XFREE(args->iv, ssl->heap, DYNAMIC_TYPE_SALT);
|
|
|
}
|
|
|
- XMEMSET(args, 0, sizeof(BuildMsgArgs));
|
|
|
}
|
|
|
+#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ ssl->options.buildArgsSet = 0;
|
|
|
+#endif
|
|
|
}
|
|
|
#endif
|
|
|
|
|
@@ -18527,9 +18558,6 @@ int BuildMessage(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
|
|
|
int ret;
|
|
|
BuildMsgArgs* args;
|
|
|
BuildMsgArgs lcl_args;
|
|
|
-#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
- args = &ssl->async.buildArgs;
|
|
|
-#endif
|
|
|
#endif
|
|
|
|
|
|
WOLFSSL_ENTER("BuildMessage");
|
|
@@ -18561,6 +18589,11 @@ int BuildMessage(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
ret = WC_NOT_PENDING_E;
|
|
|
if (asyncOkay) {
|
|
|
+ if (ssl->async == NULL) {
|
|
|
+ return BAD_FUNC_ARG;
|
|
|
+ }
|
|
|
+ args = &ssl->async->buildArgs;
|
|
|
+
|
|
|
ret = wolfSSL_AsyncPop(ssl, &ssl->options.buildMsgState);
|
|
|
if (ret != WC_NOT_PENDING_E) {
|
|
|
/* Check for error */
|
|
@@ -18580,6 +18613,9 @@ int BuildMessage(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
|
|
|
#endif
|
|
|
{
|
|
|
ret = 0;
|
|
|
+#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ ssl->options.buildArgsSet = 1;
|
|
|
+#endif
|
|
|
ssl->options.buildMsgState = BUILD_MSG_BEGIN;
|
|
|
XMEMSET(args, 0, sizeof(BuildMsgArgs));
|
|
|
|
|
@@ -20271,6 +20307,16 @@ int SendData(WOLFSSL* ssl, const void* data, int sz)
|
|
|
}
|
|
|
#endif
|
|
|
if (!ssl->options.tls1_3) {
|
|
|
+#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ if (ssl->async == NULL) {
|
|
|
+ ssl->async = (struct WOLFSSL_ASYNC*)
|
|
|
+ XMALLOC(sizeof(struct WOLFSSL_ASYNC), ssl->heap,
|
|
|
+ DYNAMIC_TYPE_ASYNC);
|
|
|
+ if (ssl->async == NULL)
|
|
|
+ return MEMORY_E;
|
|
|
+ ssl->async->freeArgs = NULL;
|
|
|
+ }
|
|
|
+#endif
|
|
|
sendSz = BuildMessage(ssl, out, outputSz, sendBuffer, buffSz,
|
|
|
application_data, 0, 0, 1, CUR_ORDER);
|
|
|
}
|
|
@@ -20290,6 +20336,9 @@ int SendData(WOLFSSL* ssl, const void* data, int sz)
|
|
|
return BUILD_MSG_ERROR;
|
|
|
}
|
|
|
|
|
|
+#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ FreeAsyncCtx(ssl, 0);
|
|
|
+#endif
|
|
|
ssl->buffers.outputBuffer.length += sendSz;
|
|
|
|
|
|
if ( (ssl->error = SendBuffered(ssl)) < 0) {
|
|
@@ -24524,8 +24573,8 @@ static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input,
|
|
|
{
|
|
|
int ret = 0;
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
- DskeArgs* args = (DskeArgs*)ssl->async.args;
|
|
|
- WOLFSSL_ASSERT_SIZEOF_GE(ssl->async.args, *args);
|
|
|
+ DskeArgs* args = NULL;
|
|
|
+ WOLFSSL_ASSERT_SIZEOF_GE(ssl->async->args, *args);
|
|
|
#else
|
|
|
DskeArgs args[1];
|
|
|
#endif
|
|
@@ -24537,6 +24586,15 @@ static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input,
|
|
|
WOLFSSL_ENTER("DoServerKeyExchange");
|
|
|
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ if (ssl->async == NULL) {
|
|
|
+ ssl->async = (struct WOLFSSL_ASYNC*)
|
|
|
+ XMALLOC(sizeof(struct WOLFSSL_ASYNC), ssl->heap,
|
|
|
+ DYNAMIC_TYPE_ASYNC);
|
|
|
+ if (ssl->async == NULL)
|
|
|
+ ERROR_OUT(MEMORY_E, exit_dske);
|
|
|
+ }
|
|
|
+ args = (DskeArgs*)ssl->async->args;
|
|
|
+
|
|
|
ret = wolfSSL_AsyncPop(ssl, &ssl->options.asyncState);
|
|
|
if (ret != WC_NOT_PENDING_E) {
|
|
|
/* Check for error */
|
|
@@ -24555,7 +24613,7 @@ static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input,
|
|
|
args->sigAlgo = ssl->specs.sig_algo;
|
|
|
args->hashAlgo = sha_mac;
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
- ssl->async.freeArgs = FreeDskeArgs;
|
|
|
+ ssl->async->freeArgs = FreeDskeArgs;
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -25531,10 +25589,13 @@ exit_dske:
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
+ /* Cleanup async */
|
|
|
+ FreeAsyncCtx(ssl, 0);
|
|
|
+#else
|
|
|
+ FreeDskeArgs(ssl, args);
|
|
|
#endif /* WOLFSSL_ASYNC_CRYPT */
|
|
|
|
|
|
/* Final cleanup */
|
|
|
- FreeDskeArgs(ssl, args);
|
|
|
FreeKeyExchange(ssl);
|
|
|
|
|
|
return ret;
|
|
@@ -25571,8 +25632,8 @@ int SendClientKeyExchange(WOLFSSL* ssl)
|
|
|
{
|
|
|
int ret = 0;
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
- SckeArgs* args = (SckeArgs*)ssl->async.args;
|
|
|
- WOLFSSL_ASSERT_SIZEOF_GE(ssl->async.args, *args);
|
|
|
+ SckeArgs* args = NULL;
|
|
|
+ WOLFSSL_ASSERT_SIZEOF_GE(ssl->async->args, *args);
|
|
|
#else
|
|
|
SckeArgs args[1];
|
|
|
#endif
|
|
@@ -25588,6 +25649,15 @@ int SendClientKeyExchange(WOLFSSL* ssl)
|
|
|
#endif
|
|
|
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ if (ssl->async == NULL) {
|
|
|
+ ssl->async = (struct WOLFSSL_ASYNC*)
|
|
|
+ XMALLOC(sizeof(struct WOLFSSL_ASYNC), ssl->heap,
|
|
|
+ DYNAMIC_TYPE_ASYNC);
|
|
|
+ if (ssl->async == NULL)
|
|
|
+ ERROR_OUT(MEMORY_E, exit_scke);
|
|
|
+ }
|
|
|
+ args = (SckeArgs*)ssl->async->args;
|
|
|
+
|
|
|
ret = wolfSSL_AsyncPop(ssl, &ssl->options.asyncState);
|
|
|
if (ret != WC_NOT_PENDING_E) {
|
|
|
/* Check for error */
|
|
@@ -25602,7 +25672,7 @@ int SendClientKeyExchange(WOLFSSL* ssl)
|
|
|
ssl->options.asyncState = TLS_ASYNC_BEGIN;
|
|
|
XMEMSET(args, 0, sizeof(SckeArgs));
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
- ssl->async.freeArgs = FreeSckeArgs;
|
|
|
+ ssl->async->freeArgs = FreeSckeArgs;
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -26737,7 +26807,12 @@ exit_scke:
|
|
|
ssl->arrays->preMasterSz = 0;
|
|
|
|
|
|
/* Final cleanup */
|
|
|
+#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ /* Cleanup async */
|
|
|
+ FreeAsyncCtx(ssl, 0);
|
|
|
+#else
|
|
|
FreeSckeArgs(ssl, args);
|
|
|
+#endif
|
|
|
FreeKeyExchange(ssl);
|
|
|
|
|
|
return ret;
|
|
@@ -26789,8 +26864,8 @@ int SendCertificateVerify(WOLFSSL* ssl)
|
|
|
{
|
|
|
int ret = 0;
|
|
|
#ifdef WOLFSSL_ASYNC_IO
|
|
|
- ScvArgs* args = (ScvArgs*)ssl->async.args;
|
|
|
- WOLFSSL_ASSERT_SIZEOF_GE(ssl->async.args, *args);
|
|
|
+ ScvArgs* args = NULL;
|
|
|
+ WOLFSSL_ASSERT_SIZEOF_GE(ssl->async->args, *args);
|
|
|
#else
|
|
|
ScvArgs args[1];
|
|
|
#endif
|
|
@@ -26799,6 +26874,14 @@ int SendCertificateVerify(WOLFSSL* ssl)
|
|
|
WOLFSSL_ENTER("SendCertificateVerify");
|
|
|
|
|
|
#ifdef WOLFSSL_ASYNC_IO
|
|
|
+ if (ssl->async == NULL) {
|
|
|
+ ssl->async = (struct WOLFSSL_ASYNC*)
|
|
|
+ XMALLOC(sizeof(struct WOLFSSL_ASYNC), ssl->heap,
|
|
|
+ DYNAMIC_TYPE_ASYNC);
|
|
|
+ if (ssl->async == NULL)
|
|
|
+ ERROR_OUT(MEMORY_E, exit_scv);
|
|
|
+ }
|
|
|
+ args = (ScvArgs*)ssl->async->args;
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
/* BuildMessage does its own Pop */
|
|
|
if (ssl->error != WC_PENDING_E ||
|
|
@@ -26826,7 +26909,7 @@ int SendCertificateVerify(WOLFSSL* ssl)
|
|
|
ssl->options.asyncState = TLS_ASYNC_BEGIN;
|
|
|
XMEMSET(args, 0, sizeof(ScvArgs));
|
|
|
#ifdef WOLFSSL_ASYNC_IO
|
|
|
- ssl->async.freeArgs = FreeScvArgs;
|
|
|
+ ssl->async->freeArgs = FreeScvArgs;
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -27190,7 +27273,12 @@ exit_scv:
|
|
|
ssl->buffers.digest.length = 0;
|
|
|
|
|
|
/* Final cleanup */
|
|
|
+#ifdef WOLFSSL_ASYNC_IO
|
|
|
+ /* Cleanup async */
|
|
|
+ FreeAsyncCtx(ssl, 0);
|
|
|
+#else
|
|
|
FreeScvArgs(ssl, args);
|
|
|
+#endif
|
|
|
FreeKeyExchange(ssl);
|
|
|
|
|
|
return ret;
|
|
@@ -27770,8 +27858,8 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|
|
{
|
|
|
int ret = 0;
|
|
|
#ifdef WOLFSSL_ASYNC_IO
|
|
|
- SskeArgs* args = (SskeArgs*)ssl->async.args;
|
|
|
- WOLFSSL_ASSERT_SIZEOF_GE(ssl->async.args, *args);
|
|
|
+ SskeArgs* args = NULL;
|
|
|
+ WOLFSSL_ASSERT_SIZEOF_GE(ssl->async->args, *args);
|
|
|
#else
|
|
|
SskeArgs args[1];
|
|
|
#endif
|
|
@@ -27780,6 +27868,14 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|
|
WOLFSSL_ENTER("SendServerKeyExchange");
|
|
|
|
|
|
#ifdef WOLFSSL_ASYNC_IO
|
|
|
+ if (ssl->async == NULL) {
|
|
|
+ ssl->async = (struct WOLFSSL_ASYNC*)
|
|
|
+ XMALLOC(sizeof(struct WOLFSSL_ASYNC), ssl->heap,
|
|
|
+ DYNAMIC_TYPE_ASYNC);
|
|
|
+ if (ssl->async == NULL)
|
|
|
+ ERROR_OUT(MEMORY_E, exit_sske);
|
|
|
+ }
|
|
|
+ args = (SskeArgs*)ssl->async->args;
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
ret = wolfSSL_AsyncPop(ssl, &ssl->options.asyncState);
|
|
|
if (ret != WC_NOT_PENDING_E) {
|
|
@@ -27804,7 +27900,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|
|
ssl->options.asyncState = TLS_ASYNC_BEGIN;
|
|
|
XMEMSET(args, 0, sizeof(SskeArgs));
|
|
|
#ifdef WOLFSSL_ASYNC_IO
|
|
|
- ssl->async.freeArgs = FreeSskeArgs;
|
|
|
+ ssl->async->freeArgs = FreeSskeArgs;
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -29307,7 +29403,12 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|
|
XFREE(args->input, ssl->heap, DYNAMIC_TYPE_IN_BUFFER);
|
|
|
args->input = NULL;
|
|
|
}
|
|
|
+ #ifdef WOLFSSL_ASYNC_IO
|
|
|
+ /* Cleanup async */
|
|
|
+ FreeAsyncCtx(ssl, 0);
|
|
|
+ #else
|
|
|
FreeSskeArgs(ssl, args);
|
|
|
+ #endif
|
|
|
FreeKeyExchange(ssl);
|
|
|
|
|
|
return ret;
|
|
@@ -30531,8 +30632,8 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|
|
{
|
|
|
int ret = 0;
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
- DcvArgs* args = (DcvArgs*)ssl->async.args;
|
|
|
- WOLFSSL_ASSERT_SIZEOF_GE(ssl->async.args, *args);
|
|
|
+ DcvArgs* args = NULL;
|
|
|
+ WOLFSSL_ASSERT_SIZEOF_GE(ssl->async->args, *args);
|
|
|
#else
|
|
|
DcvArgs args[1];
|
|
|
#endif
|
|
@@ -30541,6 +30642,15 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|
|
WOLFSSL_ENTER("DoCertificateVerify");
|
|
|
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ if (ssl->async == NULL) {
|
|
|
+ ssl->async = (struct WOLFSSL_ASYNC*)
|
|
|
+ XMALLOC(sizeof(struct WOLFSSL_ASYNC), ssl->heap,
|
|
|
+ DYNAMIC_TYPE_ASYNC);
|
|
|
+ if (ssl->async == NULL)
|
|
|
+ ERROR_OUT(MEMORY_E, exit_dcv);
|
|
|
+ }
|
|
|
+ args = (DcvArgs*)ssl->async->args;
|
|
|
+
|
|
|
ret = wolfSSL_AsyncPop(ssl, &ssl->options.asyncState);
|
|
|
if (ret != WC_NOT_PENDING_E) {
|
|
|
/* Check for error */
|
|
@@ -30559,7 +30669,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|
|
args->idx = *inOutIdx;
|
|
|
args->begin = *inOutIdx;
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
- ssl->async.freeArgs = FreeDcvArgs;
|
|
|
+ ssl->async->freeArgs = FreeDcvArgs;
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -30918,8 +31028,13 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|
|
ssl->buffers.digest.buffer = NULL;
|
|
|
ssl->buffers.digest.length = 0;
|
|
|
|
|
|
- /* Final cleanup */
|
|
|
+ #ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ /* Cleanup async */
|
|
|
+ FreeAsyncCtx(ssl, 0);
|
|
|
+ #else
|
|
|
FreeDcvArgs(ssl, args);
|
|
|
+ #endif
|
|
|
+ /* Final cleanup */
|
|
|
FreeKeyExchange(ssl);
|
|
|
|
|
|
return ret;
|
|
@@ -32120,8 +32235,8 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
|
|
|
{
|
|
|
int ret;
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
- DckeArgs* args = (DckeArgs*)ssl->async.args;
|
|
|
- WOLFSSL_ASSERT_SIZEOF_GE(ssl->async.args, *args);
|
|
|
+ DckeArgs* args = NULL;
|
|
|
+ WOLFSSL_ASSERT_SIZEOF_GE(ssl->async->args, *args);
|
|
|
#else
|
|
|
DckeArgs args[1];
|
|
|
#endif
|
|
@@ -32133,6 +32248,15 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
|
|
|
WOLFSSL_ENTER("DoClientKeyExchange");
|
|
|
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
+ if (ssl->async == NULL) {
|
|
|
+ ssl->async = (struct WOLFSSL_ASYNC*)
|
|
|
+ XMALLOC(sizeof(struct WOLFSSL_ASYNC), ssl->heap,
|
|
|
+ DYNAMIC_TYPE_ASYNC);
|
|
|
+ if (ssl->async == NULL)
|
|
|
+ ERROR_OUT(MEMORY_E, exit_dcke);
|
|
|
+ }
|
|
|
+ args = (DckeArgs*)ssl->async->args;
|
|
|
+
|
|
|
ret = wolfSSL_AsyncPop(ssl, &ssl->options.asyncState);
|
|
|
if (ret != WC_NOT_PENDING_E) {
|
|
|
/* Check for error */
|
|
@@ -32149,7 +32273,7 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
|
|
|
args->idx = *inOutIdx;
|
|
|
args->begin = *inOutIdx;
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
- ssl->async.freeArgs = FreeDckeArgs;
|
|
|
+ ssl->async->freeArgs = FreeDckeArgs;
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -33319,6 +33443,10 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
+ /* Cleanup async */
|
|
|
+ FreeAsyncCtx(ssl, 0);
|
|
|
+ #else
|
|
|
+ FreeDckeArgs(ssl, args);
|
|
|
#endif /* WOLFSSL_ASYNC_CRYPT */
|
|
|
#ifdef OPENSSL_ALL
|
|
|
/* add error ret value to error queue */
|
|
@@ -33335,7 +33463,6 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
|
|
|
ssl->arrays->preMasterSz = 0;
|
|
|
|
|
|
/* Final cleanup */
|
|
|
- FreeDckeArgs(ssl, args);
|
|
|
FreeKeyExchange(ssl);
|
|
|
|
|
|
return ret;
|
|
@@ -33388,7 +33515,7 @@ int wolfSSL_AsyncPop(WOLFSSL* ssl, byte* state)
|
|
|
}
|
|
|
|
|
|
/* check for pending async */
|
|
|
- asyncDev = ssl->async.dev;
|
|
|
+ asyncDev = ssl->asyncDev;
|
|
|
if (asyncDev) {
|
|
|
/* grab event pointer */
|
|
|
event = &asyncDev->event;
|
|
@@ -33405,7 +33532,7 @@ int wolfSSL_AsyncPop(WOLFSSL* ssl, byte* state)
|
|
|
XMEMSET(&asyncDev->event, 0, sizeof(WOLF_EVENT));
|
|
|
|
|
|
/* clear async dev */
|
|
|
- ssl->async.dev = NULL;
|
|
|
+ ssl->asyncDev = NULL;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -33450,7 +33577,7 @@ int wolfSSL_AsyncPush(WOLFSSL* ssl, WC_ASYNC_DEV* asyncDev)
|
|
|
event = &asyncDev->event;
|
|
|
|
|
|
/* store reference to active async operation */
|
|
|
- ssl->async.dev = asyncDev;
|
|
|
+ ssl->asyncDev = asyncDev;
|
|
|
|
|
|
/* place event into queue */
|
|
|
ret = wolfAsync_EventQueuePush(&ssl->ctx->event_queue, event);
|