Re: undefined reference to '_InterlockedIncrement' when compiling nss under MinGW

2012-10-09 Thread Brian Smith
weizhong qiang wrote:
 Thanks for the instruction. I tried the build of nss on with
 mozillabuild tool (with MS VC and MS SDK, using MS compiler for
 compilation) on Win7. And the build did pass.
 But the build with MinGW/MSYS (using gcc for compilation) still
 failed.

 I hope the build (with MS compiler) can be used for my software
 (which uses gcc for compilation).

If at all possible, I recommend using the MozillaBuild toolchain to build NSS, 
with OS_TARGET=WIN95, with Visual Studio 2010. That is the best-supported 
configuration on Windows because that is what we use for official builds of NSS 
for Firefox.

I am sure it must be possible to use DLLs compiled with Visual Studio in a 
program that is built with GCC, because all built-in Windows DLLs are built 
with Visual Studio. But, I am not sure how to do it.

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


Re: Accessing Mozilla NSS library functions in JavaScript-XPCOM

2012-10-09 Thread Brian Smith
Brian Teh wrote:
 Currently, my extension uses the NSS library which is coded in C++.
 But due to 6-week release cycle for Thunderbird, I am wondering
 whether are there examples on how to use Mozilla NSS for
 JavaScript-XPCOM, to avoid the need for re-compiling the binary
 components?

Currently, you should not use jsctypes or other JS-to-C++ bridges to access NSS 
in Gecko. One reason is that proper use of NSS in Gecko requires you to 
extend the native C++ nsNSSShutDownObject class in many (most? all?) 
circumstances.

The second reason is that we (Mozilla) have found it to be surprisingly 
difficult to correctly use jsctypes with NSS. In particular, you must be very 
careful that the garbage collector will not garbage collect your native code 
objects. This is one of the reasons I always recommend people to avoid jsctypes 
completely.

That said, I heard that Thunderbird is going to be based on the Gecko 17 
Extended Support Release for the next 11 months or so. That may mean you may 
not need to recompile your binary addons for Thunderbird so frequently any 
more, but I am not sure. I have CC'd Mark Banner to get clarification about 
that.

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


Re: Help: Setting Miscellaneous Data Information on PK11SymKey

2012-10-09 Thread Robert Relyea

On 10/06/2012 03:34 AM, tehhzstar wrote:

Hi,

Currently, are there any code samples available that uses 
PK11_SetSymKeyUserData, PK11_GetSymKeyUserData? I am trying to store 
information relating to PK11SymKey:

- Start Date of when the keys were created
- End Date of when the keys will expire (this is set by users)
- Calculation of duration of keys' usage.

I tried to use these functions, but it causes my extension to crash 
without any notice.


Appreciate if someone can help me on this issue. Thank you.

Regards,
Brian Teh, Singapore

The S/MIME code uses these functions in the 'static' mode.

Without having access to a stack traceback (or knowing how you are using 
the data), it's not clear where your problem lies. Some things to make 
sure of:


1) You only set data on keys you created.
2) You only get to set one user data value. This means you need to 
create a structure to hold all 3 things you are trying to set.
3) If you supply a free func, it really needs to be able to free our 
user data structure.
4) You should be able to deal with a NULL userData when you call 
PK11_GetSymKeyUserData.
5) UserData is not persistent. It is only stored with the instance of 
the key you create. If you are dealing with a token key and need to 
store persistent data, then you need to use PKCS 11 attributes and 
PK11_WriteRawAttribute() and PK11_ReadRawAttribute().. (note this may 
not work with old dbm database keys).


bob

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