* * Note that we do not want to make this test if we are in the middle of * reencypting the entire database (i.e., while execute wallet_ReencryptAll). * In that case the pref has already been changed and this test will always * fail.  That is why we test the gReencryptionLevel indicator.
PRIVATE nsresult DecryptString (const char * crypt, char *& text) {  /* treat zero-length crypt string as a special case */  if (crypt[0] == '\0') {    text = (char *)PR_Malloc(1);    text[0] = '\0';    return NS_OK;  }  /* use SecretDecoderRing if crypt doesn't starts with prefix */  if (crypt[0] != PREFIX[0]) {    if (!SI_GetBoolPref(pref_Crypto, PR_FALSE)) {      /*       * User's data is encrypted but pref says it's not.       * This should never occur but it has been observed.       * Consequence of it happening is that user will be asked for master password       * when doing such mundane things as opening edit menu or context menu.       */      NS_ASSERTION(PR_FALSE, "wallet.crypto pref is set incorrectly");      return NS_ERROR_FAILURE;    }    nsresult rv = wallet_CryptSetup();    if (NS_SUCCEEDED(rv)) {      rv = gSecretDecoderRing->DecryptString(crypt, &text);    }    if (NS_FAILED(rv)) {      gEncryptionFailure = PR_TRUE;    }    return rv;  }  /* otherwise do our own de-obscuring */  PRUint32 PREFIX_len = sizeof(PREFIX) - 1;  if (PL_strlen(crypt) == PREFIX_len) {    text = (char *)PR_Malloc(1);    text[0] = '\0';    return NS_OK;  }  text = PL_Base64Decode(&crypt[PREFIX_len], 0, NULL);  if (!text) {    return NS_ERROR_FAILURE;  }  return NS_OK;}