src/wolfSSL/src/internal.c
static int QSH_FreeAll(WOLFSSL* ssl)
{
    QSHKey* key        = ssl->QSH_Key;
    QSHKey* preKey     = NULL;
    QSHSecret* secret  = ssl->QSH_secret;
    QSHScheme* list    = NULL;
    QSHScheme* preList = NULL;

    /* free elements in struct */
    while (key) {
        preKey = key;
        if (key->pri.buffer) {
            ForceZero(key->pri.buffer, key->pri.length);
            XFREE(key->pri.buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        }
        if (key->pub.buffer)
            XFREE(key->pub.buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        key = (QSHKey*)key->next;

        /* free struct */
        XFREE(preKey, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
    }
    key = NULL;


    /* free all of peers QSH keys */
    key = ssl->peerQSHKey;
    while (key) {
        preKey = key;
        if (key->pri.buffer) {
            ForceZero(key->pri.buffer, key->pri.length);
            XFREE(key->pri.buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        }
        if (key->pub.buffer)
            XFREE(key->pub.buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        key = (QSHKey*)key->next;

        /* free struct */
        XFREE(preKey, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
    }
    key = NULL;

    /* free secret information */
    if (secret) {
        /* free up the QSHScheme list in QSHSecret */
        if (secret->list)
            list = secret->list;
        while (list) {
            preList = list;
            if (list->PK)
                XFREE(list->PK, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
            list = (QSHScheme*)list->next;
            XFREE(preList, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        }

        /* free secret buffers */
        if (secret->SerSi) {
            if (secret->SerSi->buffer) {
                /* clear extra secret material that supplemented Master Secret*/
                ForceZero(secret->SerSi->buffer, secret->SerSi->length);
                XFREE(secret->SerSi->buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
            }
            XFREE(secret->SerSi, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        }
        if (secret->CliSi) {
            if (secret->CliSi->buffer) {
                /* clear extra secret material that supplemented Master Secret*/
                ForceZero(secret->CliSi->buffer, secret->CliSi->length);
                XFREE(secret->CliSi->buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
            }
            XFREE(secret->CliSi, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        }
    }
    XFREE(secret, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
    secret = NULL;

    return 0;
}
/* free all structs that where used with QSH */
free all structs that where used with QSH
free all structs that where used with QSH
static int QSH_FreeAll(WOLFSSL* ssl)
{
    QSHKey* key        = ssl->QSH_Key;
    QSHKey* preKey     = NULL;
    QSHSecret* secret  = ssl->QSH_secret;
    QSHScheme* list    = NULL;
    QSHScheme* preList = NULL;
    while (key) {
        preKey = key;
        if (key->pri.buffer) {
            ForceZero(key->pri.buffer, key->pri.length);
            XFREE(key->pri.buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        }
        if (key->pub.buffer)
            XFREE(key->pub.buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        key = (QSHKey*)key->next;
        XFREE(preKey, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
    }
    key = NULL;
    key = ssl->peerQSHKey;
    while (key) {
        preKey = key;
        if (key->pri.buffer) {
            ForceZero(key->pri.buffer, key->pri.length);
            XFREE(key->pri.buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        }
        if (key->pub.buffer)
            XFREE(key->pub.buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        key = (QSHKey*)key->next;
        XFREE(preKey, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
    }
    key = NULL;
    if (secret) {
        if (secret->list)
            list = secret->list;
        while (list) {
            preList = list;
            if (list->PK)
                XFREE(list->PK, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
            list = (QSHScheme*)list->next;
            XFREE(preList, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        }
        if (secret->SerSi) {
            if (secret->SerSi->buffer) {
                ForceZero(secret->SerSi->buffer, secret->SerSi->length);
                XFREE(secret->SerSi->buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
            }
            XFREE(secret->SerSi, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        }
        if (secret->CliSi) {
            if (secret->CliSi->buffer) {
                ForceZero(secret->CliSi->buffer, secret->CliSi->length);
                XFREE(secret->CliSi->buffer, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
            }
            XFREE(secret->CliSi, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
        }
    }
    XFREE(secret, ssl->heap, DYNAMIC_TYPE_TMP_ARRAY);
    secret = NULL;
    return 0;
}
static int QSH_FreeAll ( WOLFSSL * ssl ) { QSHKey * key = ssl -> QSH_Key ; QSHKey * preKey = NULL ; QSHSecret * secret = ssl -> QSH_secret ; QSHScheme * list = NULL ; QSHScheme * preList = NULL ; while ( key ) { preKey = key ; if ( key -> pri . buffer ) { ForceZero ( key -> pri . buffer , key -> pri . length ) ; XFREE ( key -> pri . buffer , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; } if ( key -> pub . buffer ) XFREE ( key -> pub . buffer , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; key = ( QSHKey * ) key -> next ; XFREE ( preKey , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; } key = NULL ; key = ssl -> peerQSHKey ; while ( key ) { preKey = key ; if ( key -> pri . buffer ) { ForceZero ( key -> pri . buffer , key -> pri . length ) ; XFREE ( key -> pri . buffer , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; } if ( key -> pub . buffer ) XFREE ( key -> pub . buffer , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; key = ( QSHKey * ) key -> next ; XFREE ( preKey , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; } key = NULL ; if ( secret ) { if ( secret -> list ) list = secret -> list ; while ( list ) { preList = list ; if ( list -> PK ) XFREE ( list -> PK , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; list = ( QSHScheme * ) list -> next ; XFREE ( preList , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; } if ( secret -> SerSi ) { if ( secret -> SerSi -> buffer ) { ForceZero ( secret -> SerSi -> buffer , secret -> SerSi -> length ) ; XFREE ( secret -> SerSi -> buffer , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; } XFREE ( secret -> SerSi , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; } if ( secret -> CliSi ) { if ( secret -> CliSi -> buffer ) { ForceZero ( secret -> CliSi -> buffer , secret -> CliSi -> length ) ; XFREE ( secret -> CliSi -> buffer , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; } XFREE ( secret -> CliSi , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; } } XFREE ( secret , ssl -> heap , DYNAMIC_TYPE_TMP_ARRAY ) ; secret = NULL ; return 0 ; }
free all structs that where used with QSH
free all structs that where used with QSH
/* free elements in struct */ /* free struct */ /* free all of peers QSH keys */ /* free struct */ /* free secret information */ /* free up the QSHScheme list in QSHSecret */ /* free secret buffers */ /* clear extra secret material that supplemented Master Secret*/ /* clear extra secret material that supplemented Master Secret*/