Blame SOURCES/nss-3.79-enable-POST-rerun.patch

87e872
diff --git a/cmd/bltest/blapitest.c b/cmd/bltest/blapitest.c
87e872
--- a/cmd/bltest/blapitest.c
87e872
+++ b/cmd/bltest/blapitest.c
87e872
@@ -3870,17 +3870,17 @@ main(int argc, char **argv)
87e872
         rv = blapi_selftest(modesToTest, numModesToTest, inoff, outoff,
87e872
                             encrypt, decrypt);
87e872
         PORT_Free(cipherInfo);
87e872
         return rv == SECSuccess ? 0 : 1;
87e872
     }
87e872
 
87e872
     /* Do FIPS self-test */
87e872
     if (bltest.commands[cmd_FIPS].activated) {
87e872
-        CK_RV ckrv = sftk_FIPSEntryOK();
87e872
+        CK_RV ckrv = sftk_FIPSEntryOK(PR_FALSE);
87e872
         fprintf(stdout, "CK_RV: %ld.\n", ckrv);
87e872
         PORT_Free(cipherInfo);
87e872
         if (ckrv == CKR_OK)
87e872
             return SECSuccess;
87e872
         return SECFailure;
87e872
     }
87e872
 
87e872
     /*
87e872
diff --git a/cmd/pk11mode/pk11mode.c b/cmd/pk11mode/pk11mode.c
87e872
--- a/cmd/pk11mode/pk11mode.c
87e872
+++ b/cmd/pk11mode/pk11mode.c
87e872
@@ -318,23 +318,25 @@ static PRBool verbose = PR_FALSE;
87e872
 
87e872
 int
87e872
 main(int argc, char **argv)
87e872
 {
87e872
     CK_C_GetFunctionList pC_GetFunctionList;
87e872
     CK_FUNCTION_LIST_PTR pFunctionList;
87e872
     CK_RV crv = CKR_OK;
87e872
     CK_C_INITIALIZE_ARGS_NSS initArgs;
87e872
+    CK_C_INITIALIZE_ARGS_NSS initArgsRerun; /* rerun selftests */
87e872
     CK_SLOT_ID *pSlotList = NULL;
87e872
     CK_TOKEN_INFO tokenInfo;
87e872
     CK_ULONG slotID = 0; /* slotID == 0 for FIPSMODE */
87e872
 
87e872
     CK_UTF8CHAR *pwd = NULL;
87e872
     CK_ULONG pwdLen = 0;
87e872
     char *moduleSpec = NULL;
87e872
+    char *moduleSpecRerun = NULL;
87e872
     char *configDir = NULL;
87e872
     char *dbPrefix = NULL;
87e872
     char *disableUnload = NULL;
87e872
     PRBool doForkTests = PR_TRUE;
87e872
 
87e872
     PLOptStatus os;
87e872
     PLOptState *opt = PL_CreateOptState(argc, argv, "nvhf:Fd:p:");
87e872
     while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) {
87e872
@@ -458,18 +460,23 @@ main(int argc, char **argv)
87e872
     initArgs.CreateMutex = NULL;
87e872
     initArgs.DestroyMutex = NULL;
87e872
     initArgs.LockMutex = NULL;
87e872
     initArgs.UnlockMutex = NULL;
87e872
     initArgs.flags = CKF_OS_LOCKING_OK;
87e872
     moduleSpec = PR_smprintf("configdir='%s' certPrefix='%s' "
87e872
                              "keyPrefix='%s' secmod='secmod.db' flags= ",
87e872
                              configDir, dbPrefix, dbPrefix);
87e872
+    moduleSpecRerun = PR_smprintf("configdir='%s' certPrefix='%s' "
87e872
+                             "keyPrefix='%s' secmod='secmod.db' flags=forcePOST ",
87e872
+                             configDir, dbPrefix, dbPrefix);
87e872
     initArgs.LibraryParameters = (CK_CHAR_PTR *)moduleSpec;
87e872
     initArgs.pReserved = NULL;
87e872
+    initArgsRerun = initArgs;
87e872
+    initArgsRerun.LibraryParameters = (CK_CHAR_PTR *)moduleSpecRerun;
87e872
 
87e872
     /*DebugBreak();*/
87e872
     /* FIPSMODE invokes FC_Initialize as pFunctionList->C_Initialize */
87e872
     /* NSS cryptographic module library initialization for the FIPS  */
87e872
     /* Approved mode when FC_Initialize is envoked will perfom       */
87e872
     /* software integrity test, and power-up self-tests before       */
87e872
     /* FC_Initialize returns                                         */
87e872
     crv = pFunctionList->C_Initialize(&initArgs);
87e872
@@ -705,17 +712,17 @@ main(int argc, char **argv)
87e872
         PKM_Error("PKM_HybridMode failed with 0x%08X, %-26s\n", crv,
87e872
                   PKM_CK_RVtoStr(crv));
87e872
         goto cleanup;
87e872
     }
87e872
 
87e872
     if (doForkTests) {
87e872
         /* testing one more C_Initialize / C_Finalize to exercise getpid()
87e872
          * fork check code */
87e872
-        crv = pFunctionList->C_Initialize(&initArgs);
87e872
+        crv = pFunctionList->C_Initialize(&initArgsRerun);
87e872
         if (crv == CKR_OK) {
87e872
             PKM_LogIt("C_Initialize succeeded\n");
87e872
         } else {
87e872
             PKM_Error("C_Initialize failed with 0x%08X, %-26s\n", crv,
87e872
                       PKM_CK_RVtoStr(crv));
87e872
             goto cleanup;
87e872
         }
87e872
         crv = pFunctionList->C_Finalize(NULL);
87e872
@@ -741,16 +748,19 @@ cleanup:
87e872
         free(configDir);
87e872
     }
87e872
     if (dbPrefix) {
87e872
         free(dbPrefix);
87e872
     }
87e872
     if (moduleSpec) {
87e872
         PR_smprintf_free(moduleSpec);
87e872
     }
87e872
+    if (moduleSpecRerun) {
87e872
+        PR_smprintf_free(moduleSpecRerun);
87e872
+    }
87e872
 
87e872
 #ifdef _WIN32
87e872
     FreeLibrary(hModule);
87e872
 #else
87e872
     disableUnload = PR_GetEnvSecure("NSS_DISABLE_UNLOAD");
87e872
     if (!disableUnload) {
87e872
         PR_UnloadLibrary(lib);
87e872
     }
87e872
diff --git a/lib/freebl/blapii.h b/lib/freebl/blapii.h
87e872
--- a/lib/freebl/blapii.h
87e872
+++ b/lib/freebl/blapii.h
87e872
@@ -24,17 +24,17 @@ typedef SECStatus (*freeblAeadFunc)(void
87e872
                                     void *params, unsigned int paramsLen,
87e872
                                     const unsigned char *aad, unsigned int aadLen,
87e872
                                     unsigned int blocksize);
87e872
 typedef void (*freeblDestroyFunc)(void *cx, PRBool freeit);
87e872
 
87e872
 SEC_BEGIN_PROTOS
87e872
 
87e872
 #ifndef NSS_FIPS_DISABLED
87e872
-SECStatus BL_FIPSEntryOK(PRBool freeblOnly);
87e872
+SECStatus BL_FIPSEntryOK(PRBool freeblOnly, PRBool rerun);
87e872
 PRBool BL_POSTRan(PRBool freeblOnly);
87e872
 #endif
87e872
 
87e872
 #if defined(XP_UNIX) && !defined(NO_FORK_CHECK)
87e872
 
87e872
 extern PRBool bl_parentForkedAfterC_Initialize;
87e872
 
87e872
 #define SKIP_AFTER_FORK(x)                 \
87e872
diff --git a/lib/freebl/blapit.h b/lib/freebl/blapit.h
87e872
--- a/lib/freebl/blapit.h
87e872
+++ b/lib/freebl/blapit.h
87e872
@@ -223,16 +223,21 @@ typedef int __BLAPI_DEPRECATED __attribu
87e872
  *
87e872
  * If we arbitrarily set p = 10^-18 (1 chance in trillion trillion operation)
87e872
  * we get GCMIV_RANDOM_BIRTHDAY_BITS = -(-18)/.301 -1 = 59 (.301 = log10 2)
87e872
  * GCMIV_RANDOM_BIRTHDAY_BITS should be at least 59, call it a round 64. NOTE:
87e872
  * the variable IV size for TLS is 64 bits, which explains why it's not safe
87e872
  * to use a random value for the nonce in TLS. */
87e872
 #define GCMIV_RANDOM_BIRTHDAY_BITS 64
87e872
 
87e872
+/* flag to tell BLAPI_Verify* to rerun the post and integrity tests */
87e872
+#define BLAPI_FIPS_RERUN_FLAG '\377'  /* 0xff, 255 invalide code for UFT8/ASCII */
87e872
+#define BLAPI_FIPS_RERUN_FLAG_STRING "\377"  /* The above as a C string */
87e872
+
87e872
+
87e872
 /***************************************************************************
87e872
 ** Opaque objects
87e872
 */
87e872
 
87e872
 struct DESContextStr;
87e872
 struct RC2ContextStr;
87e872
 struct RC4ContextStr;
87e872
 struct RC5ContextStr;
87e872
diff --git a/lib/freebl/fipsfreebl.c b/lib/freebl/fipsfreebl.c
87e872
--- a/lib/freebl/fipsfreebl.c
87e872
+++ b/lib/freebl/fipsfreebl.c
87e872
@@ -2211,29 +2211,37 @@ bl_startup_tests(void)
87e872
 }
87e872
 
87e872
 /*
87e872
  * this is called from the freebl init entry points that controll access to
87e872
  * all other freebl functions. This prevents freebl from operating if our
87e872
  * power on selftest failed.
87e872
  */
87e872
 SECStatus
87e872
-BL_FIPSEntryOK(PRBool freebl_only)
87e872
+BL_FIPSEntryOK(PRBool freebl_only, PRBool rerun)
87e872
 {
87e872
 #ifdef NSS_NO_INIT_SUPPORT
87e872
     /* this should only be set on platforms that can't handle one of the INIT
87e872
     * schemes.  This code allows those platforms to continue to function,
87e872
     * though they don't meet the strict NIST requirements. If NSS_NO_INIT_SUPPORT
87e872
     * is not set, and init support has not been properly enabled, freebl
87e872
     * will always fail because of the test below
87e872
     */
87e872
     if (!self_tests_freebl_ran) {
87e872
         bl_startup_tests();
87e872
     }
87e872
 #endif
87e872
+    if (rerun) {
87e872
+        /* reset the flags */
87e872
+        self_tests_freebl_ran = PR_FALSE;
87e872
+        self_tests_success = PR_FALSE;
87e872
+        self_tests_success = PR_FALSE;
87e872
+        self_tests_freebl_success = PR_FALSE;
87e872
+        bl_startup_tests();
87e872
+    }
87e872
     /* if the general self tests succeeded, we're done */
87e872
     if (self_tests_success) {
87e872
         return SECSuccess;
87e872
     }
87e872
     /* standalone freebl can initialize */
87e872
     if (freebl_only && self_tests_freebl_success) {
87e872
         return SECSuccess;
87e872
     }
87e872
diff --git a/lib/freebl/nsslowhash.c b/lib/freebl/nsslowhash.c
87e872
--- a/lib/freebl/nsslowhash.c
87e872
+++ b/lib/freebl/nsslowhash.c
87e872
@@ -55,17 +55,17 @@ NSSLOW_Init(void)
87e872
 #ifdef FREEBL_NO_DEPEND
87e872
     (void)FREEBL_InitStubs();
87e872
 #endif
87e872
 
87e872
 #ifndef NSS_FIPS_DISABLED
87e872
     /* make sure the FIPS product is installed if we are trying to
87e872
      * go into FIPS mode */
87e872
     if (nsslow_GetFIPSEnabled()) {
87e872
-        if (BL_FIPSEntryOK(PR_TRUE) != SECSuccess) {
87e872
+        if (BL_FIPSEntryOK(PR_TRUE, PR_FALSE) != SECSuccess) {
87e872
             PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
87e872
             post_failed = PR_TRUE;
87e872
             return NULL;
87e872
         }
87e872
     }
87e872
 #endif
87e872
     post_failed = PR_FALSE;
87e872
 
87e872
diff --git a/lib/freebl/shvfy.c b/lib/freebl/shvfy.c
87e872
--- a/lib/freebl/shvfy.c
87e872
+++ b/lib/freebl/shvfy.c
87e872
@@ -282,52 +282,62 @@ readItem(PRFileDesc *fd, SECItem *item)
87e872
         PORT_Free(item->data);
87e872
         item->data = NULL;
87e872
         item->len = 0;
87e872
         return SECFailure;
87e872
     }
87e872
     return SECSuccess;
87e872
 }
87e872
 
87e872
-static PRBool blapi_SHVerifyFile(const char *shName, PRBool self);
87e872
+static PRBool blapi_SHVerifyFile(const char *shName, PRBool self, PRBool rerun);
87e872
 
87e872
 static PRBool
87e872
-blapi_SHVerify(const char *name, PRFuncPtr addr, PRBool self)
87e872
+blapi_SHVerify(const char *name, PRFuncPtr addr, PRBool self, PRBool rerun)
87e872
 {
87e872
     PRBool result = PR_FALSE; /* if anything goes wrong,
87e872
                    * the signature does not verify */
87e872
     /* find our shared library name */
87e872
     char *shName = PR_GetLibraryFilePathname(name, addr);
87e872
     if (!shName) {
87e872
         goto loser;
87e872
     }
87e872
-    result = blapi_SHVerifyFile(shName, self);
87e872
+    result = blapi_SHVerifyFile(shName, self, rerun);
87e872
 
87e872
 loser:
87e872
     if (shName != NULL) {
87e872
         PR_Free(shName);
87e872
     }
87e872
 
87e872
     return result;
87e872
 }
87e872
 
87e872
 PRBool
87e872
 BLAPI_SHVerify(const char *name, PRFuncPtr addr)
87e872
 {
87e872
-    return blapi_SHVerify(name, addr, PR_FALSE);
87e872
+    PRBool rerun = PR_FALSE;
87e872
+    if (name && *name == BLAPI_FIPS_RERUN_FLAG) {
87e872
+        name++;
87e872
+        rerun = PR_TRUE;
87e872
+    }
87e872
+    return blapi_SHVerify(name, addr, PR_FALSE, rerun);
87e872
 }
87e872
 
87e872
 PRBool
87e872
 BLAPI_SHVerifyFile(const char *shName)
87e872
 {
87e872
-    return blapi_SHVerifyFile(shName, PR_FALSE);
87e872
+    PRBool rerun = PR_FALSE;
87e872
+    if (shName && *shName == BLAPI_FIPS_RERUN_FLAG) {
87e872
+        shName++;
87e872
+        rerun = PR_TRUE;
87e872
+    }
87e872
+    return blapi_SHVerifyFile(shName, PR_FALSE, rerun);
87e872
 }
87e872
 
87e872
 static PRBool
87e872
-blapi_SHVerifyFile(const char *shName, PRBool self)
87e872
+blapi_SHVerifyFile(const char *shName, PRBool self, PRBool rerun)
87e872
 {
87e872
     char *checkName = NULL;
87e872
     PRFileDesc *checkFD = NULL;
87e872
     PRFileDesc *shFD = NULL;
87e872
     void *hashcx = NULL;
87e872
     const SECHashObject *hashObj = NULL;
87e872
     SECItem signature = { 0, NULL, 0 };
87e872
     SECItem hash;
87e872
@@ -346,17 +356,17 @@ blapi_SHVerifyFile(const char *shName, P
87e872
     unsigned char hashBuf[HASH_LENGTH_MAX];
87e872
 
87e872
     PORT_Memset(&key, 0, sizeof(key));
87e872
     hash.data = hashBuf;
87e872
     hash.len = sizeof(hashBuf);
87e872
 
87e872
     /* If our integrity check was never ran or failed, fail any other
87e872
      * integrity checks to prevent any token going into FIPS mode. */
87e872
-    if (!self && (BL_FIPSEntryOK(PR_FALSE) != SECSuccess)) {
87e872
+    if (!self && (BL_FIPSEntryOK(PR_FALSE, rerun) != SECSuccess)) {
87e872
         return PR_FALSE;
87e872
     }
87e872
 
87e872
     if (!shName) {
87e872
         goto loser;
87e872
     }
87e872
 
87e872
     /* figure out the name of our check file */
87e872
@@ -536,17 +546,17 @@ BLAPI_VerifySelf(const char *name)
87e872
 {
87e872
     if (name == NULL) {
87e872
         /*
87e872
          * If name is NULL, freebl is statically linked into softoken.
87e872
          * softoken will call BLAPI_SHVerify next to verify itself.
87e872
          */
87e872
         return PR_TRUE;
87e872
     }
87e872
-    return blapi_SHVerify(name, (PRFuncPtr)decodeInt, PR_TRUE);
87e872
+    return blapi_SHVerify(name, (PRFuncPtr)decodeInt, PR_TRUE, PR_FALSE);
87e872
 }
87e872
 
87e872
 #else /* NSS_FIPS_DISABLED */
87e872
 
87e872
 PRBool
87e872
 BLAPI_SHVerifyFile(const char *shName)
87e872
 {
87e872
     return PR_FALSE;
87e872
diff --git a/lib/softoken/fipstest.c b/lib/softoken/fipstest.c
87e872
--- a/lib/softoken/fipstest.c
87e872
+++ b/lib/softoken/fipstest.c
87e872
@@ -684,22 +684,25 @@ sftk_fips_HKDF_PowerUpSelfTest(void)
87e872
 
87e872
 static PRBool sftk_self_tests_ran = PR_FALSE;
87e872
 static PRBool sftk_self_tests_success = PR_FALSE;
87e872
 
87e872
 /*
87e872
  * This function is called at dll load time, the code tha makes this
87e872
  * happen is platform specific on defined above.
87e872
  */
87e872
-static void
87e872
-sftk_startup_tests(void)
87e872
+void sftk_startup_tests_with_rerun(PRBool rerun)
87e872
 {
87e872
     SECStatus rv;
87e872
-    const char *libraryName = SOFTOKEN_LIB_NAME;
87e872
-
87e872
+    /*const char *nlibraryName = SOFTOKEN_LIB_NAME;
87e872
+    const char *rlibraryName = BLAPI_FIPS_RERUN_FLAG_STRING SOFTOKEN_LIB_NAME; */
87e872
+    const char *libraryName = rerun ?
87e872
+               BLAPI_FIPS_RERUN_FLAG_STRING SOFTOKEN_LIB_NAME :
87e872
+               SOFTOKEN_LIB_NAME;
87e872
+    
87e872
     PORT_Assert(!sftk_self_tests_ran);
87e872
     PORT_Assert(!sftk_self_tests_success);
87e872
     sftk_self_tests_ran = PR_TRUE;
87e872
     sftk_self_tests_success = PR_FALSE; /* just in case */
87e872
 
87e872
     /* need to initiallize the oid library before the RSA tests */
87e872
     rv = SECOID_Init();
87e872
     if (rv != SECSuccess) {
87e872
@@ -746,35 +749,46 @@ sftk_startup_tests(void)
87e872
     rv = sftk_fips_pbkdf_PowerUpSelfTests();
87e872
     if (rv != SECSuccess) {
87e872
         return;
87e872
     }
87e872
 
87e872
     sftk_self_tests_success = PR_TRUE;
87e872
 }
87e872
 
87e872
+static void
87e872
+sftk_startup_tests(void)
87e872
+{
87e872
+    sftk_startup_tests_with_rerun(PR_FALSE);
87e872
+}
87e872
+
87e872
 /*
87e872
  * this is called from nsc_Common_Initizialize entry points that gates access
87e872
  * to * all other pkcs11 functions. This prevents softoken operation if our
87e872
  * power on selftest failed.
87e872
  */
87e872
 CK_RV
87e872
-sftk_FIPSEntryOK()
87e872
+sftk_FIPSEntryOK(PRBool rerun)
87e872
 {
87e872
 #ifdef NSS_NO_INIT_SUPPORT
87e872
     /* this should only be set on platforms that can't handle one of the INIT
87e872
      * schemes.  This code allows those platforms to continue to function,
87e872
      * though they don't meet the strict NIST requirements. If NSS_NO_INIT_SUPPORT
87e872
      * is not set, and init support has not been properly enabled, softken
87e872
      * will always fail because of the test below
87e872
      */
87e872
     if (!sftk_self_tests_ran) {
87e872
         sftk_startup_tests();
87e872
     }
87e872
 #endif
87e872
+    if (rerun) {
87e872
+        sftk_self_tests_ran = PR_FALSE;
87e872
+        sftk_self_tests_success = PR_FALSE;
87e872
+        sftk_startup_tests_with_rerun(PR_TRUE);
87e872
+    }
87e872
     if (!sftk_self_tests_success) {
87e872
         return CKR_DEVICE_ERROR;
87e872
     }
87e872
     return CKR_OK;
87e872
 }
87e872
 #else
87e872
 #include "pkcs11t.h"
87e872
 CK_RV
87e872
diff --git a/lib/softoken/fipstokn.c b/lib/softoken/fipstokn.c
87e872
--- a/lib/softoken/fipstokn.c
87e872
+++ b/lib/softoken/fipstokn.c
87e872
@@ -524,25 +524,32 @@ fc_log_init_error(CK_RV crv)
87e872
 }
87e872
 
87e872
 /* FC_Initialize initializes the PKCS #11 library. */
87e872
 CK_RV
87e872
 FC_Initialize(CK_VOID_PTR pReserved)
87e872
 {
87e872
     const char *envp;
87e872
     CK_RV crv;
87e872
+    PRBool rerun;
87e872
 
87e872
     if ((envp = PR_GetEnv("NSS_ENABLE_AUDIT")) != NULL) {
87e872
         sftk_audit_enabled = (atoi(envp) == 1);
87e872
     }
87e872
 
87e872
+    /* if we have the forcePOST flag on, rerun the integrity checks */
87e872
+    /* we need to know this before we fully parse the arguments in
87e872
+     * nsc_CommonInitialize, so read it now */
87e872
+    rerun = sftk_RawArgHasFlag("flags", "forcePost", pReserved);
87e872
+
87e872
     /* At this point we should have already done post and integrity checks.
87e872
      * if we haven't, it probably means the FIPS product has not been installed
87e872
-     * or the tests failed. Don't let an application try to enter FIPS mode */
87e872
-    crv = sftk_FIPSEntryOK();
87e872
+     * or the tests failed. Don't let an application try to enter FIPS mode. This
87e872
+     * also forces the tests to be rerun if forcePOST is set. */
87e872
+    crv = sftk_FIPSEntryOK(rerun);
87e872
     if (crv != CKR_OK) {
87e872
         sftk_fatalError = PR_TRUE;
87e872
         fc_log_init_error(crv);
87e872
         return crv;
87e872
     }
87e872
 
87e872
     sftk_ForkReset(pReserved, &crv;;
87e872
 
87e872
diff --git a/lib/softoken/pkcs11i.h b/lib/softoken/pkcs11i.h
87e872
--- a/lib/softoken/pkcs11i.h
87e872
+++ b/lib/softoken/pkcs11i.h
87e872
@@ -869,16 +869,17 @@ extern CK_RV sftk_MechAllowsOperation(CK
87e872
  * acquiring a reference to the keydb from the slot */
87e872
 NSSLOWKEYPrivateKey *sftk_FindKeyByPublicKey(SFTKSlot *slot, SECItem *dbKey);
87e872
 
87e872
 /*
87e872
  * parameter parsing functions
87e872
  */
87e872
 CK_RV sftk_parseParameters(char *param, sftk_parameters *parsed, PRBool isFIPS);
87e872
 void sftk_freeParams(sftk_parameters *params);
87e872
+PRBool sftk_RawArgHasFlag(const char *entry, const char *flag, const void *pReserved);
87e872
 
87e872
 /*
87e872
  * narrow objects
87e872
  */
87e872
 SFTKSessionObject *sftk_narrowToSessionObject(SFTKObject *);
87e872
 SFTKTokenObject *sftk_narrowToTokenObject(SFTKObject *);
87e872
 
87e872
 /*
87e872
diff --git a/lib/softoken/sftkpars.c b/lib/softoken/sftkpars.c
87e872
--- a/lib/softoken/sftkpars.c
87e872
+++ b/lib/softoken/sftkpars.c
87e872
@@ -244,8 +244,21 @@ sftk_freeParams(sftk_parameters *params)
87e872
     FREE_CLEAR(params->configdir);
87e872
     FREE_CLEAR(params->secmodName);
87e872
     FREE_CLEAR(params->man);
87e872
     FREE_CLEAR(params->libdes);
87e872
     FREE_CLEAR(params->tokens);
87e872
     FREE_CLEAR(params->updatedir);
87e872
     FREE_CLEAR(params->updateID);
87e872
 }
87e872
+
87e872
+PRBool
87e872
+sftk_RawArgHasFlag(const char *entry, const char *flag, const void *pReserved)
87e872
+{
87e872
+    CK_C_INITIALIZE_ARGS *init_args = (CK_C_INITIALIZE_ARGS *)pReserved;
87e872
+
87e872
+    /* if we don't have any params, the flag isn't set */
87e872
+    if ((!init_args || !init_args->LibraryParameters)) {
87e872
+        return PR_FALSE;
87e872
+    }
87e872
+
87e872
+    return NSSUTIL_ArgHasFlag(entry, flag, (const char *)init_args->LibraryParameters);
87e872
+}
87e872
diff --git a/lib/softoken/softoken.h b/lib/softoken/softoken.h
87e872
--- a/lib/softoken/softoken.h
87e872
+++ b/lib/softoken/softoken.h
87e872
@@ -52,17 +52,17 @@ extern unsigned char *CBC_PadBuffer(PLAr
87e872
                                     unsigned int inlen, unsigned int *outlen,
87e872
                                     int blockSize);
87e872
 
87e872
 /****************************************/
87e872
 /*
87e872
 ** Power-Up selftests are required for FIPS.
87e872
 */
87e872
 /* make sure Power-up selftests have been run. */
87e872
-extern CK_RV sftk_FIPSEntryOK(void);
87e872
+extern CK_RV sftk_FIPSEntryOK(PRBool rerun);
87e872
 
87e872
 /*
87e872
 ** make known fixed PKCS #11 key types to their sizes in bytes
87e872
 */
87e872
 unsigned long sftk_MapKeySize(CK_KEY_TYPE keyType);
87e872
 
87e872
 /*
87e872
 ** FIPS 140-2 auditing