/* Open and close the SSL module. These routines are called once in the lifetime of the application and initialize and clean up the library respectively. */ int32 matrixSslOpen(void) { /* Use copyright to avoid compiler warning about it being unused */ if (*copyright != 'C') { return PS_FAILURE; } if (psCoreOpen() < 0) { psError("pscore open failure\n"); return PS_FAILURE; } psInitPrng(&gMatrixsslPrng); #ifdef USE_SERVER_SIDE_SSL memset(sessionTable, 0x0, sizeof(sslSessionEntry_t) * SSL_SESSION_TABLE_SIZE); #ifdef USE_MULTITHREADING psCreateMutex(&sessionTableLock); psCreateMutex(&prngLock); #endif /* USE_MULTITHREADING */ #endif /* USE_SERVER_SIDE_SSL */ return PS_SUCCESS; }
/* Allow NULL context if caller is just doing a single read */ int32 psGetPrng(psRandom_t *ctx, unsigned char *bytes, uint32 size) { psRandom_t lctx; if (ctx == NULL) { psInitPrng(&lctx); return readRandomData(&lctx, bytes, size); } return readRandomData(ctx, bytes, size); }
/* One-time global prng lock creation and prng context */ void psOpenPrng(void) { #ifdef USE_MULTITHREADING psCreateMutex(&prngLock); #endif /* NOTE: if a PRNG is enabled, the low level psGetEntropy call can't have a useful userPtr context becuase there will be no session context at this early stage */ psInitPrng(&gMatrixPrng, NULL); gPrngInit = 1; return; }