2009/12/9 Lv, Zhiyuan <zhiyuan...@intel.com>:
> Hi,
>
> I am planning to use the HASH_HashBuf (HASH_AlgSHA256...) in my own library
> for SHA256 computing. Currently I encountered an initialization issue. Could
> someone kindly give me some suggestions? Thanks in advance!
>
> There is code like below:
>
> inited_by_myself = false;
> if (NSS_IsInitialized()) {
>     NSS_NoDB_Init ("");
>     inited_by_myself = true;
> }
>
> HASH_HashBuf();
>
> if (inited_by_myself) {
>     NSS_Shutdown();
> }
>
> But in multi-threading scenario, there could be potential errors. Even if
> adding lock to above code, I cannot solve the problem. Because my code is a
> library, other people may link the library with their code which has the NSS
> operations. I cannot ensure that the "Init" and "Shutdown" won't impact
> those operations. Comments are highly appreciated. Thanks!

This is a real issue for a library (as opposed to an application)
that uses NSS.

In NSS 3.12.5, we added the new NSS_InitContext and
NSS_ShutdownContext functions to address this issue.
Please see the NSS 3.12.5 release notes:
https://developer.mozilla.org/NSS_3.12.5_release_notes

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