/* cleanup at shutdown */ void RSA_Cleanup(void) { blindingParams * bp = NULL; if (!coBPInit.initialized) return; while (!PR_CLIST_IS_EMPTY(&blindingParamsList.head)) { RSABlindingParams *rsabp = (RSABlindingParams *)PR_LIST_HEAD(&blindingParamsList.head); PR_REMOVE_LINK(&rsabp->link); /* clear parameters cache */ while (rsabp->bp != NULL) { bp = rsabp->bp; rsabp->bp = rsabp->bp->next; mp_clear( &bp->f ); mp_clear( &bp->g ); } SECITEM_FreeItem(&rsabp->modulus,PR_FALSE); PORT_Free(rsabp); } if (blindingParamsList.cVar) { PR_DestroyCondVar(blindingParamsList.cVar); blindingParamsList.cVar = NULL; } if (blindingParamsList.lock) { SKIP_AFTER_FORK(PZ_DestroyLock(blindingParamsList.lock)); blindingParamsList.lock = NULL; } coBPInit.initialized = 0; coBPInit.inProgress = 0; coBPInit.status = 0; }
/* cleanup at shutdown */ void RSA_Cleanup(void) { if (!coBPInit.initialized) return; while (!PR_CLIST_IS_EMPTY(&blindingParamsList.head)) { struct RSABlindingParamsStr * rsabp = (struct RSABlindingParamsStr *) PR_LIST_HEAD(&blindingParamsList.head); PR_REMOVE_LINK(&rsabp->link); mp_clear(&rsabp->f); mp_clear(&rsabp->g); SECITEM_FreeItem(&rsabp->modulus,PR_FALSE); PORT_Free(rsabp); } if (blindingParamsList.lock) { SKIP_AFTER_FORK(PZ_DestroyLock(blindingParamsList.lock)); blindingParamsList.lock = NULL; } coBPInit.initialized = 0; coBPInit.inProgress = 0; coBPInit.status = 0; }
/* * Clean up the global RNG context */ static void prng_freeRNGContext(RNGContext *rng) { PRUint8 inputhash[VSize(rng) + (sizeof rng->C)]; /* destroy context lock */ SKIP_AFTER_FORK(PZ_DestroyLock(globalrng->lock)); /* zero global RNG context except for C & V to preserve entropy */ prng_Hash_df(inputhash, sizeof rng->C, rng->C, sizeof rng->C, NULL, 0); prng_Hash_df(&inputhash[sizeof rng->C], VSize(rng), V(rng), VSize(rng), NULL, 0); memset(rng, 0, sizeof *rng); memcpy(rng->C, inputhash, sizeof rng->C); memcpy(V(rng), &inputhash[sizeof rng->C], VSize(rng)); memset(inputhash, 0, sizeof inputhash); }