Looking at a startup profile in Quantify, I'm not sure that skipping the DB initialization will help. The majority of the time seems to be going to initializing the random number generator (ReadSystemFiles, called from RNG_SystemInfoForRNG). Or am I missing something that would cause this all to be skipped?

Brian Ryner wrote:
I'll do some profiling to make sure it's the DB initialization that's causing the performance hit.

I guess maybe I should have mentioned that I'm currently using these methods through the nsICryptoHash XPCOM wrapper. So we'd either need to change that object to know that it can do a NoDB_Init if full initialization hasn't happened yet, or I could switch over to using the NSS functions directly. Are there any problems with a Firefox extension linking directly to NSS?

Thanks,


Wan-Teh Chang wrote:

Brian Ryner wrote:

Hi,

Is it possible to use the HASH_* NSS functions before NSS_Init has been
called? I'd like to defer the full initialization while still being able to
run an MD5 hash.



You must initialize NSS.  However, there is a
way to initialize NSS for such simple things:
NSS_NoDB_Init.  Please try this sample code.

  #include "nss.h"

  PRBool inited_nss = PR_FALSE;

  if (!NSS_IsInitialized()) {
      NSS_NoDB_Init(NULL);
      inited_nss = PR_TRUE;
  }

  /* call the HASH_* NSS functions */
  ...

  if (inited_nss) {
      NSS_Shutdown();
  }

So, if the app has already initialized NSS,
you just go ahead and use NSS functions.  Else,
you have to initialize NSS (in the "no database"
mode) first, and have to shut down NSS.

This sample code assumes that this thread is
the only thread that may initialize NSS in the
app.

Wan-Teh
_______________________________________________
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to