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!

Regards,
-Zhiyuan

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

Reply via email to