if (rv != SECSuccess) { SECU_PrintPRandOSError(PROGRAM_NAME); exit(-1); }
InitCrypto(char *cert_dir, PRBool readOnly){  SECStatus rv;  static int prior = 0;	PK11SlotInfo *slotinfo;  CERTCertDBHandle *db;	if (prior == 0) {		/* some functions such as OpenKeyDB expect this path to be		 * implicitly set prior to calling */		if (readOnly) {		   NSS_Init(cert_dir);		} else {		    NSS_InitReadWrite(cert_dir);		}		SECU_ConfigDirectory (cert_dir);		/* Been there done that */		prior++;		if(password) {			PK11_SetPasswordFunc(pk11_password_hardcode);		} 		/* Must login to FIPS before you do anything else */		if(PK11_IsFIPS()) {			slotinfo = PK11_GetInternalSlot();			if(!slotinfo) {				fprintf(stderr, "%s: Unable to get PKCS #11 Internal Slot."				  "\n", PROGRAM_NAME);				return -1;			}			if(PK11_Authenticate(slotinfo, PR_FALSE /*loadCerts*/,			  NULL /*wincx*/) != SECSuccess) {				fprintf(stderr, "%s: Unable to authenticate to %s.\n",					PROGRAM_NAME, PK11_GetSlotName(slotinfo));				return -1;			}		}		/* Make sure there is a password set on the internal key slot */		slotinfo = PK11_GetInternalKeySlot();		if(!slotinfo) {			fprintf(stderr, "%s: Unable to get PKCS #11 Internal Key Slot."			  "\n", PROGRAM_NAME);			return -1;		}		if(PK11_NeedUserInit(slotinfo)) {			PR_fprintf(errorFD,"\nWARNING: No password set on internal key database.  Most operations will fail.""\nYou must use Communicator to create a password.\n");			warningCount++;		}		/* Make sure we can authenticate to the key slot in FIPS mode */		if(PK11_IsFIPS()) {			if(PK11_Authenticate(slotinfo, PR_FALSE /*loadCerts*/,			  NULL /*wincx*/) != SECSuccess) {				fprintf(stderr, "%s: Unable to authenticate to %s.\n",					PROGRAM_NAME, PK11_GetSlotName(slotinfo));				return -1;			}		}	}	return 0;}