if (displayAllCerts) PR_fprintf(PR_STDERR, "-C option is not implemented in this version\n");  if (displayAllSigners) PR_fprintf(PR_STDERR, "-S option is not implemented in this version\n");
int main(int argc, char **argv){	PRExplodedTime explodedCurrent;	SECItem der, data;	char *progName;	int rv;	PRFileDesc *dataFile = 0;	PRFileDesc *signFile = 0;	FILE *outFile = stdout;	char *typeTag = 0;	PRBool displayAllCerts = PR_FALSE;	PRBool displayAllSigners = PR_FALSE;	SECStatus secstatus;	secuCommand signver;	signver.numCommands = sizeof(signver_commands) /sizeof(secuCommandFlag);	signver.numOptions = sizeof(signver_options) / sizeof(secuCommandFlag);	signver.commands = signver_commands;	signver.options = signver_options;#ifdef XP_PC	progName = strrchr(argv[0], '\\');#else	progName = strrchr(argv[0], '/');#endif	progName = progName ? progName+1 : argv[0];	/*_asm int 3*/	PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &explodedCurrent);#if 0	if (explodedCurrent.tm_year >= 1998		&& explodedCurrent.tm_month >= 5 /* months past tm_year (0-11, Jan = 0) */		&& explodedCurrent.tm_mday >= 1) {		PR_fprintf(PR_STDERR, "%s: expired\n", progName);		return -1;	}#endif	SECU_ParseCommandLine(argc, argv, progName, &signver);	/*  Set the certdb directory (default is ~/.{browser}) */	SECU_ConfigDirectory(signver.options[opt_CertDir].arg);	/*  Set the certificate type.  */	typeTag = SECU_GetOptionArg(&signver, opt_TypeTag);	/*  -i and -s without filenames  */	if (signver.options[opt_InputDataFile].activated &&	    signver.options[opt_InputSigFile].activated &&	    !signver.options[opt_InputDataFile].arg &&	    !signver.options[opt_InputSigFile].arg)		PR_fprintf(PR_STDERR, 	              "%s: Only data or signature file can use stdin (not both).\n",	              progName);	/*  Open the input data file (no arg == use stdin). */	if (signver.options[opt_InputDataFile].activated) {		if (signver.options[opt_InputDataFile].arg)			dataFile = PR_Open(signver.options[opt_InputDataFile].arg, 			                   PR_RDONLY, 0);		else			dataFile = PR_STDIN;		if (!dataFile) {			PR_fprintf(PR_STDERR, "%s: unable to open \"%s\" for reading.\n",			           progName, signver.options[opt_InputDataFile].arg);			return -1;		}	}	/*  Open the input signature file (no arg == use stdin).  */	if (signver.options[opt_InputSigFile].activated) {		if (signver.options[opt_InputSigFile].arg)			signFile = PR_Open(signver.options[opt_InputSigFile].arg, 			                   PR_RDONLY, 0);		else			signFile = PR_STDIN;		if (!signFile) {			PR_fprintf(PR_STDERR, "%s: unable to open \"%s\" for reading.\n",			           progName, signver.options[opt_InputSigFile].arg);			return -1;		}	}#if 0				if (!typeTag) ascii = 1;#endif	/*  Open|Create the output file.  */	if (signver.options[opt_OutputFile].activated) {		outFile = fopen(signver.options[opt_OutputFile].arg, "w");			/*		outFile = PR_Open(signver.options[opt_OutputFile].arg,		                  PR_WRONLY|PR_CREATE_FILE|PR_TRUNCATE, 00660);						  */		if (!outFile) {			PR_fprintf(PR_STDERR, "%s: unable to open \"%s\" for writing.\n",			           progName, signver.options[opt_OutputFile].arg);			return -1;		}	}	if (signver.commands[cmd_DisplayCertInfo].activated &&	    !signver.options[opt_ItemNumber].arg)		displayAllCerts = PR_TRUE;	if (signver.commands[cmd_DisplaySignerInfo].activated &&	    !signver.options[opt_ItemNumber].arg)		displayAllSigners = PR_TRUE;#if 0			case 'W':				debugInfo = 1;				break;#endif	if (!signFile && !dataFile && !typeTag) 		Usage(progName, outFile);	if (!signFile && !dataFile && 	     signver.commands[cmd_VerifySignedObj].activated) {		PR_fprintf(PR_STDERR, 		           "%s: unable to read all data from standard input\n", 		           progName);		return -1;	} 	PR_SetError(0, 0); /* PR_Init("pp", 1, 1, 0);*/	secstatus = NSS_Init(SECU_ConfigDirectory(NULL));    	if (secstatus != SECSuccess) {	    SECU_PrintPRandOSError(progName);	    return -1;	}	SECU_RegisterDynamicOids();	rv = SECU_ReadDERFromFile(&der, signFile, 	                          signver.options[opt_ASCII].activated);	/* Data is untyped, using the specified type */	data.data = der.data;	data.len = der.len;	/* Signature Verification */	if (!signver.options[opt_TypeTag].activated) {		if (signver.commands[cmd_VerifySignedObj].activated) {			SEC_PKCS7ContentInfo *cinfo;			cinfo = SEC_PKCS7DecodeItem(&data, NULL, NULL, NULL, NULL,			                            NULL, NULL, NULL);			if (cinfo != NULL) {#if 0				if (debugInfo) {					PR_fprintf(PR_STDERR, "Content %s encrypted.\n",							   SEC_PKCS7ContentIsEncrypted(cinfo) ? "was" : "was not");					PR_fprintf(PR_STDERR, "Content %s signed.\n",							   SEC_PKCS7ContentIsSigned(cinfo) ? "was" : "was not");				}#endif				if (SEC_PKCS7ContentIsSigned(cinfo)) {					SEC_PKCS7SignedData *signedData;					HASH_HashType digestType;					SECItem digest, data;					unsigned char *dataToVerify, digestBuffer[32];					signedData = cinfo->content.signedData;					/* assume that there is only one digest algorithm for now */					digestType = 					  AlgorithmToHashType(signedData->digestAlgorithms[0]);					if (digestType == HASH_AlgNULL) {						PR_fprintf(PR_STDERR, "Invalid hash algorithmID\n");						return (-1);					}					rv = SECU_FileToItem(&data, dataFile);					dataToVerify = data.data;					if (dataToVerify) {						                   /*certUsageObjectSigner;*/						SECCertUsage usage = certUsageEmailSigner; 						#if 0						if (debugInfo) 							PR_fprintf(PR_STDERR, "dataToVerify=%s\n", 							           dataToVerify);#endif						digest.data = digestBuffer;						if (DigestData (digest.data, dataToVerify, 						                &digest.len, 32, digestType)) {							PR_fprintf(PR_STDERR, "Fail to compute message digest for verification. Reason: %s\n",									  SECU_ErrorString((int16)PORT_GetError()));							return (-1);						}#if 0						if (debugInfo) {							PR_fprintf(PR_STDERR, "Data Digest=:");							for (i = 0; i < digest.len; i++)								PR_fprintf(PR_STDERR, "%02x:", digest.data[i]);							PR_fprintf(PR_STDERR, "\n");						}#endif						if (signver.commands[cmd_VerifySignedObj].activated)							fprintf(outFile, "signatureValid=");						PORT_SetError(0);						if (SEC_PKCS7VerifyDetachedSignature (cinfo, usage, 						                       &digest, digestType, PR_FALSE)) {							if (signver.commands[cmd_VerifySignedObj].activated)								fprintf(outFile, "yes");						} else {							if (signver.commands[cmd_VerifySignedObj].activated){								fprintf(outFile, "no");							if (signver.options[opt_PrintWhyFailure].activated)							fprintf(outFile, ":%s", SECU_ErrorString((int16)PORT_GetError()));							}						}						if (signver.commands[cmd_VerifySignedObj].activated)							fprintf(outFile, "\n");						SECITEM_FreeItem(&data, PR_FALSE);					} else {						PR_fprintf(PR_STDERR, "Cannot read data\n");						return (-1);					}				}				SEC_PKCS7DestroyContentInfo(cinfo);			} else				PR_fprintf(PR_STDERR, "Unable to decode PKCS7 data\n");		}		if (signver.commands[cmd_DisplayAllPCKS7Info].activated)			SV_PrintPKCS7ContentInfo(outFile, &data);		if (displayAllCerts)			PR_fprintf(PR_STDERR, "-C option is not implemented in this version\n");		if (displayAllSigners)			PR_fprintf(PR_STDERR, "-S option is not implemented in this version\n");	/* Pretty print it */	} else if (PL_strcmp(typeTag, SEC_CT_CERTIFICATE) == 0) {		rv = SECU_PrintSignedData(outFile, &data, "Certificate", 0,								  SECU_PrintCertificate);	} else if (PL_strcmp(typeTag, SEC_CT_CERTIFICATE_REQUEST) == 0) {		rv = SECU_PrintSignedData(outFile, &data, "Certificate Request", 0,								  SECU_PrintCertificateRequest);	} else if (PL_strcmp (typeTag, SEC_CT_CRL) == 0) {		rv = SECU_PrintSignedData (outFile, &data, "CRL", 0, SECU_PrintCrl);#ifdef HAVE_EPK_TEMPLATE	} else if (PL_strcmp(typeTag, SEC_CT_PRIVATE_KEY) == 0) {		rv = SECU_PrintPrivateKey(outFile, &data, "Private Key", 0);#endif	} else if (PL_strcmp(typeTag, SEC_CT_PUBLIC_KEY) == 0) {		rv = SECU_PrintPublicKey(outFile, &data, "Public Key", 0);	} else if (PL_strcmp(typeTag, SEC_CT_PKCS7) == 0) {		rv = SECU_PrintPKCS7ContentInfo(outFile, &data,										"PKCS #7 Content Info", 0);	} else {		PR_fprintf(PR_STDERR, "%s: don't know how to print out '%s' files\n",				   progName, typeTag);		return -1;	}	if (rv) {		PR_fprintf(PR_STDERR, "%s: problem converting data (%s)\n",				   progName, SECU_ErrorString((int16)PORT_GetError()));		return -1;	}       if (NSS_Shutdown() != SECSuccess) {           exit(1);       }	return 0;}