src/wolfSSL/src/internal.c
void FreeHandshakeResources(WOLFSSL* ssl)
{

    HashFinal(ssl) ;
#ifdef HAVE_SECURE_RENEGOTIATION
    if (ssl->secure_renegotiation && ssl->secure_renegotiation->enabled) {
        WOLFSSL_MSG("Secure Renegotiation needs to retain handshake resources");
        return;
    }
#endif

    /* input buffer */
    if (ssl->buffers.inputBuffer.dynamicFlag)
        ShrinkInputBuffer(ssl, NO_FORCED_FREE);

    /* suites */
    XFREE(ssl->suites, ssl->heap, DYNAMIC_TYPE_SUITES);
    ssl->suites = NULL;

    /* hsHashes */
    XFREE(ssl->hsHashes, ssl->heap, DYNAMIC_TYPE_HASHES);
    ssl->hsHashes = NULL;

    /* RNG */
    if (ssl->specs.cipher_type == stream || ssl->options.tls1_1 == 0) {
        wc_FreeRng(ssl->rng);
        XFREE(ssl->rng, ssl->heap, DYNAMIC_TYPE_RNG);
        ssl->rng = NULL;
    }

#ifdef WOLFSSL_DTLS
    /* DTLS_POOL */
    if (ssl->options.dtls) {
        DtlsPoolDelete(ssl);
        DtlsMsgListDelete(ssl->dtls_msg_list, ssl->heap);
        ssl->dtls_msg_list = NULL;
    }
#endif

    /* arrays */
    if (ssl->options.saveArrays == 0)
        FreeArrays(ssl, 1);

#ifndef NO_RSA
    /* peerRsaKey */
    if (ssl->peerRsaKey) {
        wc_FreeRsaKey(ssl->peerRsaKey);
        XFREE(ssl->peerRsaKey, ssl->heap, DYNAMIC_TYPE_RSA);
        ssl->peerRsaKey = NULL;
    }
#endif

#ifdef HAVE_ECC
    if (ssl->peerEccKey)
    {
        if (ssl->peerEccKeyPresent) {
            wc_ecc_free(ssl->peerEccKey);
            ssl->peerEccKeyPresent = 0;
        }
        XFREE(ssl->peerEccKey, ssl->heap, DYNAMIC_TYPE_ECC);
        ssl->peerEccKey = NULL;
    }
    if (ssl->peerEccDsaKey)
    {
        if (ssl->peerEccDsaKeyPresent) {
            wc_ecc_free(ssl->peerEccDsaKey);
            ssl->peerEccDsaKeyPresent = 0;
        }
        XFREE(ssl->peerEccDsaKey, ssl->heap, DYNAMIC_TYPE_ECC);
        ssl->peerEccDsaKey = NULL;
    }
    if (ssl->eccTempKey)
    {
        if (ssl->eccTempKeyPresent) {
            wc_ecc_free(ssl->eccTempKey);
            ssl->eccTempKeyPresent = 0;
        }
        XFREE(ssl->eccTempKey, ssl->heap, DYNAMIC_TYPE_ECC);
        ssl->eccTempKey = NULL;
    }
#endif
#ifndef NO_DH
    if (ssl->buffers.serverDH_Priv.buffer) {
        ForceZero(ssl->buffers.serverDH_Priv.buffer,
                                             ssl->buffers.serverDH_Priv.length);
    }
    XFREE(ssl->buffers.serverDH_Priv.buffer, ssl->heap, DYNAMIC_TYPE_DH);
    ssl->buffers.serverDH_Priv.buffer = NULL;
    XFREE(ssl->buffers.serverDH_Pub.buffer, ssl->heap, DYNAMIC_TYPE_DH);
    ssl->buffers.serverDH_Pub.buffer = NULL;
    /* parameters (p,g) may be owned by ctx */
    if (ssl->buffers.weOwnDH || ssl->options.side == WOLFSSL_CLIENT_END) {
        XFREE(ssl->buffers.serverDH_G.buffer, ssl->heap, DYNAMIC_TYPE_DH);
        ssl->buffers.serverDH_G.buffer = NULL;
        XFREE(ssl->buffers.serverDH_P.buffer, ssl->heap, DYNAMIC_TYPE_DH);
        ssl->buffers.serverDH_P.buffer = NULL;
    }
#endif
#ifndef NO_CERTS
    wolfSSL_UnloadCertsKeys(ssl);
#endif
#ifdef HAVE_PK_CALLBACKS
    #ifdef HAVE_ECC
        XFREE(ssl->buffers.peerEccDsaKey.buffer, ssl->heap, DYNAMIC_TYPE_ECC);
        ssl->buffers.peerEccDsaKey.buffer = NULL;
    #endif /* HAVE_ECC */
    #ifndef NO_RSA
        XFREE(ssl->buffers.peerRsaKey.buffer, ssl->heap, DYNAMIC_TYPE_RSA);
        ssl->buffers.peerRsaKey.buffer = NULL;
    #endif /* NO_RSA */
#endif /* HAVE_PK_CALLBACKS */

#ifdef HAVE_QSH
    QSH_FreeAll(ssl);
#endif
}
/* Free any handshake resources no longer needed */
Free any handshake resources no longer needed
Free any handshake resources no longer needed
void FreeHandshakeResources(WOLFSSL* ssl)
{
    HashFinal(ssl) ;
#ifdef HAVE_SECURE_RENEGOTIATION
    if (ssl->secure_renegotiation && ssl->secure_renegotiation->enabled) {
        WOLFSSL_MSG("Secure Renegotiation needs to retain handshake resources");
        return;
    }
#endif
    if (ssl->buffers.inputBuffer.dynamicFlag)
        ShrinkInputBuffer(ssl, NO_FORCED_FREE);
    XFREE(ssl->suites, ssl->heap, DYNAMIC_TYPE_SUITES);
    ssl->suites = NULL;
    XFREE(ssl->hsHashes, ssl->heap, DYNAMIC_TYPE_HASHES);
    ssl->hsHashes = NULL;
    if (ssl->specs.cipher_type == stream || ssl->options.tls1_1 == 0) {
        wc_FreeRng(ssl->rng);
        XFREE(ssl->rng, ssl->heap, DYNAMIC_TYPE_RNG);
        ssl->rng = NULL;
    }
#ifdef WOLFSSL_DTLS
    if (ssl->options.dtls) {
        DtlsPoolDelete(ssl);
        DtlsMsgListDelete(ssl->dtls_msg_list, ssl->heap);
        ssl->dtls_msg_list = NULL;
    }
#endif
    if (ssl->options.saveArrays == 0)
        FreeArrays(ssl, 1);
#ifndef NO_RSA
    if (ssl->peerRsaKey) {
        wc_FreeRsaKey(ssl->peerRsaKey);
        XFREE(ssl->peerRsaKey, ssl->heap, DYNAMIC_TYPE_RSA);
        ssl->peerRsaKey = NULL;
    }
#endif
#ifdef HAVE_ECC
    if (ssl->peerEccKey)
    {
        if (ssl->peerEccKeyPresent) {
            wc_ecc_free(ssl->peerEccKey);
            ssl->peerEccKeyPresent = 0;
        }
        XFREE(ssl->peerEccKey, ssl->heap, DYNAMIC_TYPE_ECC);
        ssl->peerEccKey = NULL;
    }
    if (ssl->peerEccDsaKey)
    {
        if (ssl->peerEccDsaKeyPresent) {
            wc_ecc_free(ssl->peerEccDsaKey);
            ssl->peerEccDsaKeyPresent = 0;
        }
        XFREE(ssl->peerEccDsaKey, ssl->heap, DYNAMIC_TYPE_ECC);
        ssl->peerEccDsaKey = NULL;
    }
    if (ssl->eccTempKey)
    {
        if (ssl->eccTempKeyPresent) {
            wc_ecc_free(ssl->eccTempKey);
            ssl->eccTempKeyPresent = 0;
        }
        XFREE(ssl->eccTempKey, ssl->heap, DYNAMIC_TYPE_ECC);
        ssl->eccTempKey = NULL;
    }
#endif
#ifndef NO_DH
    if (ssl->buffers.serverDH_Priv.buffer) {
        ForceZero(ssl->buffers.serverDH_Priv.buffer,
                                             ssl->buffers.serverDH_Priv.length);
    }
    XFREE(ssl->buffers.serverDH_Priv.buffer, ssl->heap, DYNAMIC_TYPE_DH);
    ssl->buffers.serverDH_Priv.buffer = NULL;
    XFREE(ssl->buffers.serverDH_Pub.buffer, ssl->heap, DYNAMIC_TYPE_DH);
    ssl->buffers.serverDH_Pub.buffer = NULL;
    if (ssl->buffers.weOwnDH || ssl->options.side == WOLFSSL_CLIENT_END) {
        XFREE(ssl->buffers.serverDH_G.buffer, ssl->heap, DYNAMIC_TYPE_DH);
        ssl->buffers.serverDH_G.buffer = NULL;
        XFREE(ssl->buffers.serverDH_P.buffer, ssl->heap, DYNAMIC_TYPE_DH);
        ssl->buffers.serverDH_P.buffer = NULL;
    }
#endif
#ifndef NO_CERTS
    wolfSSL_UnloadCertsKeys(ssl);
#endif
#ifdef HAVE_PK_CALLBACKS
    #ifdef HAVE_ECC
        XFREE(ssl->buffers.peerEccDsaKey.buffer, ssl->heap, DYNAMIC_TYPE_ECC);
        ssl->buffers.peerEccDsaKey.buffer = NULL;
    #endif 
    #ifndef NO_RSA
        XFREE(ssl->buffers.peerRsaKey.buffer, ssl->heap, DYNAMIC_TYPE_RSA);
        ssl->buffers.peerRsaKey.buffer = NULL;
    #endif 
#endif 
#ifdef HAVE_QSH
    QSH_FreeAll(ssl);
#endif
}
void FreeHandshakeResources ( WOLFSSL * ssl ) { HashFinal ( ssl ) ; #ifdef HAVE_SECURE_RENEGOTIATION if ( ssl -> secure_renegotiation && ssl -> secure_renegotiation -> enabled ) { WOLFSSL_MSG ( " " ) ; return ; } #endif if ( ssl -> buffers . inputBuffer . dynamicFlag ) ShrinkInputBuffer ( ssl , NO_FORCED_FREE ) ; XFREE ( ssl -> suites , ssl -> heap , DYNAMIC_TYPE_SUITES ) ; ssl -> suites = NULL ; XFREE ( ssl -> hsHashes , ssl -> heap , DYNAMIC_TYPE_HASHES ) ; ssl -> hsHashes = NULL ; if ( ssl -> specs . cipher_type == stream || ssl -> options . tls1_1 == 0 ) { wc_FreeRng ( ssl -> rng ) ; XFREE ( ssl -> rng , ssl -> heap , DYNAMIC_TYPE_RNG ) ; ssl -> rng = NULL ; } #ifdef WOLFSSL_DTLS if ( ssl -> options . dtls ) { DtlsPoolDelete ( ssl ) ; DtlsMsgListDelete ( ssl -> dtls_msg_list , ssl -> heap ) ; ssl -> dtls_msg_list = NULL ; } #endif if ( ssl -> options . saveArrays == 0 ) FreeArrays ( ssl , 1 ) ; #ifndef NO_RSA if ( ssl -> peerRsaKey ) { wc_FreeRsaKey ( ssl -> peerRsaKey ) ; XFREE ( ssl -> peerRsaKey , ssl -> heap , DYNAMIC_TYPE_RSA ) ; ssl -> peerRsaKey = NULL ; } #endif #ifdef HAVE_ECC if ( ssl -> peerEccKey ) { if ( ssl -> peerEccKeyPresent ) { wc_ecc_free ( ssl -> peerEccKey ) ; ssl -> peerEccKeyPresent = 0 ; } XFREE ( ssl -> peerEccKey , ssl -> heap , DYNAMIC_TYPE_ECC ) ; ssl -> peerEccKey = NULL ; } if ( ssl -> peerEccDsaKey ) { if ( ssl -> peerEccDsaKeyPresent ) { wc_ecc_free ( ssl -> peerEccDsaKey ) ; ssl -> peerEccDsaKeyPresent = 0 ; } XFREE ( ssl -> peerEccDsaKey , ssl -> heap , DYNAMIC_TYPE_ECC ) ; ssl -> peerEccDsaKey = NULL ; } if ( ssl -> eccTempKey ) { if ( ssl -> eccTempKeyPresent ) { wc_ecc_free ( ssl -> eccTempKey ) ; ssl -> eccTempKeyPresent = 0 ; } XFREE ( ssl -> eccTempKey , ssl -> heap , DYNAMIC_TYPE_ECC ) ; ssl -> eccTempKey = NULL ; } #endif #ifndef NO_DH if ( ssl -> buffers . serverDH_Priv . buffer ) { ForceZero ( ssl -> buffers . serverDH_Priv . buffer , ssl -> buffers . serverDH_Priv . length ) ; } XFREE ( ssl -> buffers . serverDH_Priv . buffer , ssl -> heap , DYNAMIC_TYPE_DH ) ; ssl -> buffers . serverDH_Priv . buffer = NULL ; XFREE ( ssl -> buffers . serverDH_Pub . buffer , ssl -> heap , DYNAMIC_TYPE_DH ) ; ssl -> buffers . serverDH_Pub . buffer = NULL ; if ( ssl -> buffers . weOwnDH || ssl -> options . side == WOLFSSL_CLIENT_END ) { XFREE ( ssl -> buffers . serverDH_G . buffer , ssl -> heap , DYNAMIC_TYPE_DH ) ; ssl -> buffers . serverDH_G . buffer = NULL ; XFREE ( ssl -> buffers . serverDH_P . buffer , ssl -> heap , DYNAMIC_TYPE_DH ) ; ssl -> buffers . serverDH_P . buffer = NULL ; } #endif #ifndef NO_CERTS wolfSSL_UnloadCertsKeys ( ssl ) ; #endif #ifdef HAVE_PK_CALLBACKS #ifdef HAVE_ECC XFREE ( ssl -> buffers . peerEccDsaKey . buffer , ssl -> heap , DYNAMIC_TYPE_ECC ) ; ssl -> buffers . peerEccDsaKey . buffer = NULL ; #endif #ifndef NO_RSA XFREE ( ssl -> buffers . peerRsaKey . buffer , ssl -> heap , DYNAMIC_TYPE_RSA ) ; ssl -> buffers . peerRsaKey . buffer = NULL ; #endif #endif #ifdef HAVE_QSH QSH_FreeAll ( ssl ) ; #endif }
Free any handshake resources no longer needed
Free any handshake resources no longer needed
/* input buffer */ /* suites */ /* hsHashes */ /* RNG */ /* DTLS_POOL */ /* arrays */ /* peerRsaKey */ /* parameters (p,g) may be owned by ctx */ /* HAVE_ECC */ /* NO_RSA */ /* HAVE_PK_CALLBACKS */