Re: Developing pkcs11 module for Firefox
On 29. 12. 2011 23:08, Brian Smith wrote: Matej Kurpel wrote: On 22. 12. 2011 10:36, Imen Ibn Hotab wrote: I`m developing pkcs#11 module for Firefox. I was developing a PKCS#11 module as well. Just out of curiosity, what do your PKCS#11 modules do? Would it make things easier for either of you if Firefox and Thunderbird supported CAPI CSPs in addition or instead of pkcs#11 modules for client certificates on Windows? Cheers, Brian It made a cryptographic device out of any Windows Mobile-powered phone (and capable of running .NET framework programs). It was my diploma thesis which I defended successfully :) I would not even think of using CAPI for this purpose just because it is Windows-only and more programs are PKCS#11-friendly than CAPI-friendly (afaik, at least). M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Developing pkcs11 module for Firefox
On 22. 12. 2011 10:36, Imen Ibn Hotab wrote: Hi all! I`m developing pkcs#11 module for Firefox. Now I`m testing on my windows XP machine. When I try to load my module using graphic interface in Mozilla Firefox 8.0.1 I have "unable to load module" message. I try to load my module in Firefox 6.0 but have same message. When I use Mozilla/5.0 Firefox/3.6.9 module loaded successful. Have anyone such problem? Hello, I was developing a PKCS#11 module as well. To debug PKCS#11 calls from Firefox to your module, I recommend using pkcs11-spy.dll from the OpenSC package. It allows you to write all data to a file so you can review what went wrong. Hope this helps M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: does anyone try to use AES_CBC ???
On 22. 7. 2011 18:36, Brian Smith wrote: - Original Message - From: "Matej Kurpel" On 22 juil, 14:41, helpcrypto helpcrypto wrote: at this time, i had just to make some test about the AES_CBC or AES_ECB like time to encrypt, time to decrypt,how memory used, how cpu used for just a simple operation . for tis kind of test private key and IV will be set in the programm not given by secure way. Take a look at this code. I pieced this together by looking at lib/ssl/ssl3con.c. It is probably very similar to the code in cmd/digest. I have not tested it, compiled it, or even thought about it much. Also, I left out all the error handling to mislead you into thinking that your final code will be readable. /* const SECItem * input; holds plaintext data SECItem * output; will hold encrypted data unsigned maxout; size of output->data buffer */ output->data = NULL; output->len = 0; PK11SlotInfo *slot = PK11_GetInternalSlot(); PK11Context *context = NULL; PK11Symkey * aesKey = NULL; SECItem *param = NULL; /* This is not the proper way to deal with key material in a real application. keyData is a pointer to a SECItem that holds the raw key, and ivData is a pointer to a SECItem that holds the IV. */ aesKey = PK11_ImportSymKey(slot, CKM_AES_CBC, PK11_OriginUnwrap, CKA_ENCRYPT, keyData, NULL); param = PK11_ParamFromIV(CKM_AES_CBC, iv); context = PK11_CreateContextBySymKey(CKM_AES_CBC, CKA_ENCRYPT, aesKey, param); PK11_CipherOp(context, output->data,&output->len, maxout, input->data, input->len); PK11_DestroyContext(context, PR_TRUE); PK11_FreeSlot(slot); OpenSSL is intended for this purpose, not NSS. ... Cheers, Brian But NSS gets the key using PKCS#11 from a token. And you need to get it from a file directly (or a variable). -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: does anyone try to use AES_CBC ???
On 22. 7. 2011 15:09, florent ainardi wrote: On 22 juil, 14:41, helpcrypto helpcrypto wrote: As i tell you a few minutes ago, i have working code for openssl AES_CBC operations using a certificate. All the info its available at openssl.org (im not very happy with the doc, but its enough) Im migrating some apps at the moment, so ill review that code in next months, ask anything if needed. 2011/7/22 florent ainardi: hi all does anyone try to use or implement encrypt function with AES_CBC with NSS MOZILLA 3.12.10 please tell me how ? does it works ? regards -- dev-tech-crypto mailing list dev-tech-cry...@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto On 22 juil, 14:41, helpcrypto helpcrypto wrote: As i tell you a few minutes ago, i have working code for openssl AES_CBC operations using a certificate. All the info its available at openssl.org (im not very happy with the doc, but its enough) Im migrating some apps at the moment, so ill review that code in next months, ask anything if needed. 2011/7/22 florent ainardi: hi all does anyone try to use or implement encrypt function with AES_CBC with NSS MOZILLA 3.12.10 please tell me how ? does it works ? regards -- dev-tech-crypto mailing list dev-tech-cry...@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto ok i understand. let me just explain the task i had to do i'm working on a project that use cryptographic function like encrypt and decrypt with the AES algorithm. at this time, i had just to make some test about the AES_CBC or AES_ECB like time to encrypt, time to decrypt,how memory used, how cpu used for just a simple operation . for tis kind of test private key and IV will be set in the programm not given by secure way. this is the first part of my project, after that i had to check other point, but my priority is to use nss mozilla, to make a little benchmark and that's all. if you can help me to use this libs in this way you're welcome you can contact me in private at : fainard...@gmail.com if you want to tell me more about nss mozilla regards OpenSSL is intended for this purpose, not NSS. Why do you want to use NSS anyway? -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Adding a PKCS#11 module when device is not connected
Hello, I am developing a PKCS#11 module and I would like to improve it a bit - let me explain: Currently, when adding a new PKCS#11 module via the GUI (or modutil), the module is not added when it returns CKR_DEVICE_REMOVED on C_Initialize and it says a rather nothing-saying error message "Unable to add module". I would like to be able to add the module even when the device is not connected to the computer. My colleagues told me that USB tokens "iKey" are shipped with a PKCS#11 module which does this. My question is: what should I do to my PKCS#11 module so that it could be added even when the device is not currently connected to the computer? I just know that I can't return CKR_OK on C_Initialize because more calls would be requested for such as device name, and, obviously, I cannot get such information without the device being connected. Thanks to all replies, M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Two-factor auth for Bugzilla
On 3. 2. 2011 9:21, Anders Rundgren wrote: Matej Kurpel wrote: On 2. 2. 2011 13:37, Gervase Markham wrote: On 01/02/11 18:08, Matej Kurpel wrote: @Q4: I am doing this as my diploma thesis, it works for Windows Mobile phones/PDAs and is tested with Firefox and Thunderbird. Certificate login works fine in Firefox. Can you tell us a bit more about this? How does what you are doing compare to http://motp.sourceforge.net/? Gerv My solution is completely different - mobile phone acts as an ordinary cryptographic token - it contains private/public keys and personal certificates. You just install a PKCS#11 module in Firefox and set up an application on your mobile phone and are ready to go. Private keys are encrypted and a passphrase is asked for everytime the use of private key is requested. That's the REAL STUFF! Virtual "cards" and PIN-code terminal in one unit. What's missing are standards including on-line provisioning of keys. Long-term I believe credential selection will move to the phone which though requires an entirely different mechanism than PKCS #11. Out of curiosity - why a different mechanism than PKCS#11? Is there anything other than CryptoAPI from M$? A. Rundgren M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Two-factor auth for Bugzilla
On 2. 2. 2011 13:37, Gervase Markham wrote: On 01/02/11 18:08, Matej Kurpel wrote: @Q4: I am doing this as my diploma thesis, it works for Windows Mobile phones/PDAs and is tested with Firefox and Thunderbird. Certificate login works fine in Firefox. Can you tell us a bit more about this? How does what you are doing compare to http://motp.sourceforge.net/? Gerv My solution is completely different - mobile phone acts as an ordinary cryptographic token - it contains private/public keys and personal certificates. You just install a PKCS#11 module in Firefox and set up an application on your mobile phone and are ready to go. Private keys are encrypted and a passphrase is asked for everytime the use of private key is requested. M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Two-factor auth for Bugzilla
On 1. 2. 2011 17:56, Gervase Markham wrote: Dear crypto-hackers, Your thoughts on the following problem would be appreciated. Goal: fix bug 570252. Provide 2-factor authentication for some Bugzilla accounts. https://bugzilla.mozilla.org/show_bug.cgi?id=570252 Sub-goal: do it in a way which doesn't involve purchasing or running proprietary software. General musings on these goals welcome. Here also are some specific questions: Q1) There is conflicting advice in that bug about whether a client certificate-based solution can meet the requirement of "implement it only for some accounts" (with the implicit requirement that it doesn't bother or affect people who are not using it). Can a client certificate solution be made to work? Q2) If not, does anyone know of any commercial 2-factor systems which can be implemented entirely with open source tools and software? (I'd accept having to purchase closed hardware tokens.) Q3) If not, can we do something smart like issue chip cards and leverage the devices being shipped for the rollout of the Chip Authentication Program in various countries? http://en.wikipedia.org/wiki/Pinsentry Q4) Or, could we do something in-browser or with a phone app, allowing people to use their mobile phone as the hardware token? @Q4: I am doing this as my diploma thesis, it works for Windows Mobile phones/PDAs and is tested with Firefox and Thunderbird. Certificate login works fine in Firefox. M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: S/MIME encrypted e-mails
On 30. 1. 2011 10:57, Nelson B Bolyard wrote: On 2011-01-29 06:41 PDT, Matej Kurpel wrote: Hello, as far as I know, Thunderbird sends encrypted e-mails as an attachment named "smime.p7m". Can anybody let me briefly know what this file contains? Yes, it contains a message in the "Cryptographic Message Syntax" (CMS). CMS is NOT SIMPLE. To understand how it works, and its role in SMIME you really should read and grasp the related IETF RFC standards. They're not small, nor for the faint of heart. But if you want to grok CMS, there's no shortcut.. On second thought, there might be some textbooks... Does that mean the p7m file contains multiple copies of the same message, each copy encrypted using a different key? No. Well ... depends on how you define "the same message". The email message (or other major payload) is encrypted once with one key using some symmetric cipher (e.g. AES). Then (in some sense) that one key (which is small) becomes a new message, which is separately encrypted multiple times, once for each recipient. Yes, the P7M holds all those encrypted copies of the key that encrypts the main message, and of course, the ciphertext produced with that key, And cert chains, and capabilities, and ... it's like bread from Bembleman's Bakery, it's what everyone wants. :) Thank you. Is the symmetric (e.g. AES) key encrypted directly with public keys of the recipients or is it encrypted using some more ephemeral symmetric keys for each recipient and those ephemeral keys are encrypted using the public keys? I thought the second was true but now it wouldn't make sense... Need to clarify it for myself :) Also, it looks like it contains some certificates. Unfortunately, the software I am using (ASN.1 Editor) doesn't read the p7m file despite the fact that it looks as a DER-encoded file at a first glance (even after removing the zero-byte padding). Not DER. It's BER. Zero-byte padding? Indefinite length encoding! Anyone can shed some light on the contents of "smime.p7m" ? Thanks in advance, M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
S/MIME encrypted e-mails
Hello, as far as I know, Thunderbird sends encrypted e-mails as an attachment named "smime.p7m". Can anybody let me briefly know what this file contains? I know this from previous e-mail conversation from this mailing list: "The sender generates an ephemeral 3-DES key one for each receiver, then encrypts (wraps) each key using that receivers' RSA public key. In order to read a message, you have to decrypt (unwrap) the 3-DES key that was encrypted using your RSA public key. Then, you have to decrypt the messsage using the 3-DES key you just unwrapped." Does that mean the p7m file contains multiple copies of the same message, each copy encrypted using a different key? Also, it looks like it contains some certificates. Unfortunately, the software I am using (ASN.1 Editor) doesn't read the p7m file despite the fact that it looks as a DER-encoded file at a first glance (even after removing the zero-byte padding). Anyone can shed some light on the contents of "smime.p7m" ? Thanks in advance, M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: "Unable to add module", but why?
On 25. 1. 2011 1:17, Daniel Veditz wrote: Forwarding question to the mozilla.dev.tech.crypto group. Is this a module you're creating yourself, or one you know works fine with Firefox for other people? On 1/21/11 6:21 PM, Lbm wrote: Hi, first of all I hope I'm posting this question in the right place. Anyway, I've been trying to add a specific PKCS#11 module to Firefox and keep getting the, rather uninformative, message "Unable to add module". What I'd like to know is how one might be able to get some more info on _why_ the module can't be loaded? Also noticed that one can debug modules using a specific environment variable, but since the actual module is never loaded at all that's pretty much a no go. Any info would be really appreciated! Well, I used to have the same problem and I have successfully used the pkcs11-spy.dll drom the OpenSC package. It sits between your module and Firefox and writes all PKCS#11 function calls to a file. There you can see what exactly went wrong. Hope this helps, M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: NSS SoftToken Capabilities
On 5. 1. 2011 21:33, Anders Rundgren wrote: Matej Kurpel wrote: On 4. 1. 2011 22:23, Robert Relyea wrote: On 01/03/2011 01:04 PM, Anders Rundgren wrote: Hi, I'm in the starting phase upgrading Firefox so that it can provision credentials in a way that that banks and governments require which among many things include E2ES (End-to-End Security) and issuer- specified PIN-codes (or just policies for user-defined dittos). The plan is mainly focusing on (enhanced) HW-tokens which NSS due to its PKCS #11 heritage doesn't support with any of the above. However, for "soft tokens" where all is running in user-space, the distinction between middleware and the container is mostly academic so it could be an idea supporting the NSS softtoken. Unfortunately, I know rather little about NSS so I wonder if the idea is feasible or not. Q1: Is is correct that you can only have a single PIN for all soft tokens? You have a single pin per 'slot'. Any PKCS #11 module can implement multiple slots. You can even cause the NSS softoken to have multiple slots. I also think that there is a definition on how to do key specific pins in the later versions of PKCS #11. I think it involves using a special user type, with the key operation already selected in the current session. I'd have to go back and look, it might also just be I'm remembering the AUTHENTICATE_ALWAYS semantic. Yes, it's CKA_ALWAYS_AUTHENTICATE attribute set to TRUE for a private key and, unfortunately, NSS currently does not support this. I don't know exactly how to interpret this... Does the softoken support PINs or not? From what I know, it does not. It only supports a token-wide PIN (or Password). Try opening up your Security Devices manager in Firefox or Thunderbird, select Software security device from the left pane and as you can see, you can only change a password for the whole token. (I don't really know if there is one or if it's taken into account... I have never used the software security device explicitly). Maybe someone another in this list could shed some light on this... How do you set it from Firefox? OTOH, it would be strange if it did since none of the "upstream" components like has any support for PIN provisioning. Most serious users of "soft token" PKI due that distributes their own provisioning and keystore SW and that won't change because I say it should. It probably takes Apple or Google to get the priorities straight ;-) anders Q2: Is it possible to add arbitrary data attributes to a key? I need such in order to support credential logotypes and information cards. If these general token types, I suggest getting them added to the PKCS #11 working group. PKCS #11 also allows vendor defined attributes and objects. We use these to supply NSS specific operations and objects, that aren't generally interesting to the PKCS #11 group as a whole. If the ideas are generally usable by a myriad of tokens, then trying to get them defined in the working group is best. CKA_VENDOR_SPECIFIC (0x800) and above. For example, NSS uses some vendor-specific attributes such as the value of CKO_NETSCAPE_CRL for CKA_CLASS attribute. You can implement such vendor-specific attribute as well. There is also an already define generic 'data' object. If these objects aren't really attached to the key , then it's own object type would make more sense. bob thanx, Anders M. Kurpel M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: NSS SoftToken Capabilities
On 4. 1. 2011 22:23, Robert Relyea wrote: On 01/03/2011 01:04 PM, Anders Rundgren wrote: Hi, I'm in the starting phase upgrading Firefox so that it can provision credentials in a way that that banks and governments require which among many things include E2ES (End-to-End Security) and issuer- specified PIN-codes (or just policies for user-defined dittos). The plan is mainly focusing on (enhanced) HW-tokens which NSS due to its PKCS #11 heritage doesn't support with any of the above. However, for "soft tokens" where all is running in user-space, the distinction between middleware and the container is mostly academic so it could be an idea supporting the NSS softtoken. Unfortunately, I know rather little about NSS so I wonder if the idea is feasible or not. Q1: Is is correct that you can only have a single PIN for all soft tokens? You have a single pin per 'slot'. Any PKCS #11 module can implement multiple slots. You can even cause the NSS softoken to have multiple slots. I also think that there is a definition on how to do key specific pins in the later versions of PKCS #11. I think it involves using a special user type, with the key operation already selected in the current session. I'd have to go back and look, it might also just be I'm remembering the AUTHENTICATE_ALWAYS semantic. Yes, it's CKA_ALWAYS_AUTHENTICATE attribute set to TRUE for a private key and, unfortunately, NSS currently does not support this. Q2: Is it possible to add arbitrary data attributes to a key? I need such in order to support credential logotypes and information cards. If these general token types, I suggest getting them added to the PKCS #11 working group. PKCS #11 also allows vendor defined attributes and objects. We use these to supply NSS specific operations and objects, that aren't generally interesting to the PKCS #11 group as a whole. If the ideas are generally usable by a myriad of tokens, then trying to get them defined in the working group is best. CKA_VENDOR_SPECIFIC (0x800) and above. For example, NSS uses some vendor-specific attributes such as the value of CKO_NETSCAPE_CRL for CKA_CLASS attribute. You can implement such vendor-specific attribute as well. There is also an already define generic 'data' object. If these objects aren't really attached to the key , then it's own object type would make more sense. bob thanx, Anders M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Thunderbird crashing when C_SignInit returns other than CKR_OK
On 27. 12. 2010 18:15, Nelson B Bolyard wrote: On 2010-12-27 01:44 PDT, Matej Kurpel wrote: If I only was able to load the source code of Thunderbird in Visual Studio, that would be great. I could debug it line-by-line as usual. You can. Download and unpack the sources from ftp://ftp.mozilla.org/pub/thunderbird/releases/latest-3.1/source/thunderbird-3.1.7.source.tar.bz2 (or substitute the release you're running, as needed). You don't need to build it yourself. Use the symbol server (You've already done this step, IIRC). Just tell your debugger where you put the sources locally. Wow - I was able to "Attach To Process..." in VS2008 and then I caused the crash deliberately. It showed me the source code and call stack, which is great. But evaluating most of the variables returned "CXX0069: Error: variable needs stack frame". No idea what that means. The source code is far too complex for me to understand anyway :( I am sending you the call stack as VS displayed it to me. It crashed on a line in nsGlobalWindow.cpp saying: nsWindowSH::InvalidateGlobalScopePolluter(cx, currentInner->mJSObject); saying Uncaught exception occurred. Call stack: >thunderbird.exe!nsGlobalWindow::SetNewDocument(nsIDocument * aDocument=0x00a02c00, nsISupports * aState=0x, int aClearScopeHint=0x0001, int aIsInternalCall=0x000b) Line 1760 + 0x3 bytesC++ thunderbird.exe!nsGlobalWindow::SetNewDocument(nsIDocument * aDocument=0x00a02c00, nsISupports * aState=0x, int aClearScopeHint=0x0001) Line 1569C++ thunderbird.exe!DocumentViewerImpl::InitInternal(nsIWidget * aParentWidget=0x04e498c0, nsISupports * aState=0x, const nsIntRect & aBounds={...}, int aDoCreation=0x0001, int aInPrintPreview=0x, int aNeedMakeCX=0x0001) Line 960C++ thunderbird.exe!DocumentViewerImpl::Init(nsIWidget * aParentWidget=0x00a79580, const nsIntRect & aBounds={...}) Line 699C++ thunderbird.exe!nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer=0x04e8c3c0) Line 7304 + 0x1b bytesC++ thunderbird.exe!nsDocShell::Embed(nsIContentViewer * aContentViewer=0x04e8c3c0, const char * aCommand=0x01ab0481, nsISupports * aExtraInfo=0x) Line 5472C++ thunderbird.exe!nsDocShell::CreateContentViewer(const char * aContentType=0x03c37d68, nsIRequest * request=0x050c6740, nsIStreamListener * * aContentHandler=0x050c6740) Line 7090 + 0x15 bytesC++ thunderbird.exe!nsDSURIContentListener::DoContent(const char * aContentType=0x03c37d68, int aIsContentPreferred=0x, nsIRequest * request=0x050c6740, nsIStreamListener * * aContentHandler=0x04effb5c, int * aAbortProcess=0x0045ac48) Line 150C++ thunderbird.exe!nsDocumentOpenInfo::TryContentListener(nsIURIContentListener * aListener=0x06eb4e80, nsIChannel * aChannel=0x04effb5c) Line 734C++ thunderbird.exe!nsDocumentOpenInfo::DispatchContent(nsIRequest * request=0x050c6740, nsISupports * aCtxt=0x) Line 434 + 0x15 bytesC++ thunderbird.exe!nsDocumentOpenInfo::OnStartRequest(nsIRequest * request=0x050c6740, nsISupports * aCtxt=0x) Line 287C++ thunderbird.exe!nsJARChannel::OnStartRequest(nsIRequest * req=0x05bac330, nsISupports * ctx=0x) Line 867 + 0x16 bytesC++ thunderbird.exe!nsInputStreamPump::OnStateStart() Line 445C++ thunderbird.exe!nsInputStreamPump::OnInputStreamReady(nsIAsyncInputStream * stream=0x04e7cb68) Line 407C++ xpcom_core.dll!nsOutputStreamReadyEvent::Run() Line 113C++ xpcom_core.dll!nsThread::ProcessNextEvent(int mayWait=0x0001, int * result=0x0045aef0) Line 527 + 0x6 bytesC++ xpcom_core.dll!NS_ProcessNextEvent_P(nsIThread * thread=0x0001, int mayWait=0x0001) Line 250 + 0xd bytesC++ xpcom_core.dll!nsThread::Shutdown() Line 468 + 0xa bytesC++ thunderbird.exe!nsSound::PurgeLastSound() Line 140C++ thunderbird.exe!nsSound::~nsSound() Line 135C++ thunderbird.exe!nsSound::`scalar deleting destructor'() + 0x8 bytesC++ thunderbird.exe!nsIndexedToHTML::Release() Line 62 + 0x18 bytesC++ thunderbird.exe!XPCJSRuntime::GCCallback(JSContext * cx=0x04f1d400, JSGCStatus status=JSGC_END) Line 760 + 0x2a bytesC++ thunderbird.exe!DOMGCCallback(JSContext * cx=0x04f1d400, JSGCStatus status=JSGC_END) Line 3827 + 0x14 bytesC++ thunderbird.exe!XPCCycleCollectGCCallback(JSContext * cx=0x04f1d400, JSGCStatus status=JSGC_END) Line 412 + 0x10 bytesC++ js3250.dll!js_GC(JSContext * cx=0x04f1d400, JSGCInvocationKind gckind=GC_NORMAL) Line 3822 + 0x5 bytesC++ js3250.dll!JS_GC(JSContext * cx=0x04f1d400) Line 2439 + 0x8 bytesC++ thunderbird.exe!nsXPConnect::Collect() Line 479C++ xpcom_core.dll!nsCycleCollector::Collect(unsigned int aTryCollections=0x00
Re: Thunderbird crashing when C_SignInit returns other than CKR_OK
On 21. 12. 2010 15:35, Marsh Ray wrote: On 12/21/2010 06:44 AM, Matej Kurpel wrote: How can I check if I am doing something bad to the heap, please? Sadly, I am not so skilled C++ programmer (well, rather a noobish one) and I mostly don't know about the inside stuff you were talking about here... It's OK, everybody has to debug this problem occasionally. Also, the code for C_SignInit is nearly the same as for C_DecryptInit which works fine. Plus, when I only return non-CKR_OK error code from C_SignInit (and do nothing else in it), it still crashes. 1. Go over all your code again and make sure nothing is writing past the end of the memory you get from new/malloc, or someone else gives to you. Search in your code for 'memcopy' and friends, a bad parameter to those functions can easily cause this. Search for C-style (casts) of pointers and reinterpret_cast. I did. I have avoided memcpy (or any mem-related functions) just in case anyway. 2. Make sure you don't pass a pointer to some object which remembers it and then delete/free the pointer while that object is still using it. Try simply commenting out everywhere you manually free memory. It will be a memory leak, but you might be able to figure out which one(s) cause the crash that way. I don't free memory manually. The module is just a set of short C functions so the variables are freed up automatically anyway. 3. See if you can reproduce the problem on Linux. Run it with Valgrind and/or Electric Fence These are similar to PageHeap, often times open source apps will already have a build configuration for that on Linux. Can't test it on Linux since I am using the MS-only functions (like sprintf_s). And my implementation of sockets use Winsock. Well, that's the "interoperability" of C++ I guess... I don't have the time and nerves to fiddle around with it in Linux anyway. 4. Test it with Microsoft's PageHeap tool. There's lots of documentation on it and probably some forums that can help you with that. If that doesn't find it right away, try re-building with the Release Microsoft C Runtime library as discussed. I have tried the PageHeap tool as you suggested. I have managed to enable PageHeap for thunderbird.exe but then I was unable to figure out what the output from that tool is? Does it write a log file for me somewhere? Or how do I check the output of PageHeap? From what I have read on Microsoft's PageHeap web page, they suggest trying Application Verifier as an GUI alternative to PageHeap. I tried it as well but when thunderbird.exe was added as an applicatin to verify, I couldn't start it (it said "The application was unable to start correctly (0xc142). Click OK to close the application"). I tried both the x86 and x64 versions of Application Verifier, with same results. I guess I am out of options here. I would like to solve this problem very much. If I can be of more help - if you need more info (or output from some more debugging programs), just ask. You can do it. - Marsh If I only was able to load the source code of Thunderbird in Visual Studio, that would be great. I could debug it line-by-line as usual. Why does it have to be so hard? :( M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Thunderbird crashing when C_SignInit returns other than CKR_OK
On 19. 12. 2010 9:27, Nelson Bolyard wrote: On 2010-12-16 19:21 PDT, Marsh Ray wrote: On 12/16/2010 04:39 PM, Matej Kurpel wrote: ChildEBP RetAddr Args to Child 0015f130 5fa0c52b e06d7363 0001 0003 KERNELBASE!RaiseException+0x58 (FPO: [Non-Fpo]) 0015f168 5fa14f13 0015f178 5fa7aa24 5fa5c11c MOZCRT19!_CxxThrowException+0x46 (FPO: [Non-Fpo]) (CONV: stdcall) [f:\sp\vctools\crt_bld\self_x86\crt\prebuild\eh\throw.cpp @ 161] So Mozilla builds its own CRT without FPO, cool. Yes, Mozilla builds its own CRT, which is a modified version of the MSVC CRT, whose sources come only with the pay (not free) versions of MSVC. They do this in order to replace MSVC's normal heap code (malloc) with their own "JEmalloc". Mozilla's source repository doesn't include ANY of the MSVC source code, but only includes a ed script that patches that source without including any of it. Sadly, this means that people with the free MSVC cannot build MOZCRT19, because they lack the sources to be patched. IMO, this is a flaw for an open source project, but ... :( 0015f180 003b474b 0028 0015f290 5f9ad1d9 MOZCRT19!operator new+0x73 (FPO: [1,3,0]) (CONV: cdecl) The above func must be statically linked from the Mic CRT into the Moz CRT. So it's still FPO. Weird. Right. IIRC, it's built from the plain old MSVC new.cpp source. It calls malloc and throws an exception if malloc returns NULL. [e:\buildbot\win32_build_31\build\objdir-tb\mozilla\memory\jemalloc\crtsrc\new@61] Looking at http://mxr.mozilla.org/mozilla-central/source/memory/jemalloc/ I don't see the source or crtsrc\new.cpp. Must be copied in from Microsoft source code a build time. Right. In any case, 'operator new' is throwing a C++ exception. Ordinarily that would be due to a bad parameter (e.g., -1) or lack of memory. Right. Any NULL return from malloc causes this. In this case is it maybe asking for 0x0028 = 40 bytes? I wouldn't bet much money that JEmalloc never modifies its input arguments. That's always allowed in c (as you know) which always passes arguments by value. 0015f198 003b47db 09385800 003d3b55 thunderbird!nsDOMEvent::nsDOMEvent+0x63 (FPO: [Non-Fpo]) (CONV: thiscall) [e:\buildbot\win32_build_31\build\mozilla\content\events\src\nsdomevent@136] http://mxr.mozilla.org/mozilla-central/source/content/events/src/nsDOMEvent.cpp Line 132 is in the middle of a comment, so clearly I'm n ot looking at the right source. Below it is a 'new nsEvent'. The sources from which Thunderbird are built come from Mozilla's "comm-central" repository. I think that line 136 could be either a reference to the line on which the "new" call itself occurs, or the following line. The versions of the nsdomevent source in which the new call occurs on line 135 are dated 2009-04-02 14:34 -0500 ... 2009-06-30 10:56 +0300 and line 136 from 2009-09-11 16:13 -0700 ... 2009-11-30 13:31 -0500 all of which are over a year old now. See http://hg.mozilla.org/mozilla-central/log/90b17476216d/content/events/src/nsDOMEvent.cpp and http://hg.mozilla.org/mozilla-central/log/d9267e3d8f8c/content/events/src/nsDOMEvent.cpp and http://hg.mozilla.org/mozilla-central/annotate/9e7a2c507c41/content/events/src/nsDOMEvent.cpp#l136 But 'nsEvent' looks like it would take more than 40 bytes. yes. So, skipping down a bit, it looks like something has already gone wrong before this exception is thrown. The app is attempting to show an alert box, which fails because of an out-of-memory condition. Agreed. further back on the stack, we see: nsMsgSendReport::DisplayReport+0x28c nsmsgsendreport@428] nsMsgComposeAndSend::Fail+0x73nsmsgsend@3812] nsMsgComposeAndSend::GatherMimeAttachments+0x113d nsmsgsend@1147] That suggests that the attempt to generate and attach all the attachments failed, and I'd guess that is likely due to Matej's intentional introduction of a failure into C_SignInit. So, C_SignInit failed, and then the attempt to report that failure in an alert pop-up dialog fails due to heap allocation failure, perhaps due to heap exhaustion, or heap corruption. The details are probably not important. Well, I think the big question is: why does the heap allocation fail? You need to track down where the first error occurs. My first wild guess is that Matej's PKCS#11 module is doing something bad to the heap. My second one is that NSS or PSM is trying to free to the MOZCRT17 heap something that was allocated from another heap. How can I check if I am doing something bad to the heap, please? Sadly, I am not so skilled C++ programmer (well, rather a noobish one) and I mostly don't know about the inside stuff you were talking about here... Also, the code for C_SignInit is nearly the same as for C_DecryptInit which works fine. Plus, when I only return non-CKR_OK error code from C_SignIn
Re: Thunderbird crashing when C_SignInit returns other than CKR_OK
On 16. 12. 2010 21:59, Marsh Ray wrote: On 12/16/2010 01:02 PM, Matej Kurpel wrote: (164c.1560): C++ EH exception - code e06d7363 (first chance) Nelson may know more specifics, but if I were you I would configure the debugger to break when C++ exceptions are thrown. (Debug menu -> Event filters) When it break here, type "kv100" to get the stack trace. The full listing of Command window is as follows: Microsoft (R) Windows Debugger Version 6.12.0002.633 AMD64 Copyright (c) Microsoft Corporation. All rights reserved. CommandLine: "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" Symbol search path is: SRV*c:\symcache\*http://msdl.microsoft.com/download/symbols;SRV*c:\symcache\*http://symbols.mozilla.org/firefox;SRV*c:\symcache\*http://symbols.mozilla.org/thunderbird Executable search path is: ModLoad: `0016 `00d7c000 thunderbird.exe ModLoad: `77ab `77c5b000 ntdll.dll ModLoad: `77c9 `77e1 ntdll32.dll ModLoad: `756d `7570f000 C:\Windows\SYSTEM32\wow64.dll ModLoad: `7567 `756cc000 C:\Windows\SYSTEM32\wow64win.dll ModLoad: `7566 `75668000 C:\Windows\SYSTEM32\wow64cpu.dll (1120.11b0): Break instruction exception - code 8003 (first chance) ntdll!LdrpDoDebuggerBreak+0x30: `77b61340 cc int 3 0:000> g ModLoad: `7789 `779af000 WOW64_IMAGE_SECTION ModLoad: `7662 `7672 WOW64_IMAGE_SECTION ModLoad: `7789 `779af000 NOT_AN_IMAGE ModLoad: `779b `77aaa000 NOT_AN_IMAGE ModLoad: `7662 `7672 C:\Windows\syswow64\kernel32.dll ModLoad: `7675 `76796000 C:\Windows\syswow64\KERNELBASE.dll ModLoad: `5fa9 `5fb61000 C:\Program Files (x86)\Mozilla Thunderbird\js3250.dll ModLoad: `6bf6 `6bf8a000 C:\Program Files (x86)\Mozilla Thunderbird\nspr4.dll ModLoad: `762c `7636 C:\Windows\syswow64\ADVAPI32.dll ModLoad: `7621 `762bc000 C:\Windows\syswow64\msvcrt.dll ModLoad: `7776 `9000 C:\Windows\SysWOW64\sechost.dll ModLoad: `7586 `7595 C:\Windows\syswow64\RPCRT4.dll ModLoad: `7580 `7586 C:\Windows\syswow64\SspiCli.dll ModLoad: `757f `757fc000 C:\Windows\syswow64\CRYPTBASE.dll ModLoad: `734f `734f7000 C:\Windows\SysWOW64\WSOCK32.dll ModLoad: `75b8 `75bb5000 C:\Windows\syswow64\WS2_32.dll ModLoad: `7648 `76486000 C:\Windows\syswow64\NSI.dll ModLoad: `719d `71a02000 C:\Windows\SysWOW64\WINMM.dll ModLoad: `7652 `7662 C:\Windows\syswow64\USER32.dll ModLoad: `7780 `7789 C:\Windows\syswow64\GDI32.dll ModLoad: `7637 `7637a000 C:\Windows\syswow64\LPK.dll ModLoad: `763d `7646d000 C:\Windows\syswow64\USP10.dll ModLoad: `5f9e `5fa9 C:\Program Files (x86)\Mozilla Thunderbird\MOZCRT19.dll ModLoad: `5f97 `5f9d5000 C:\Program Files (x86)\Mozilla Thunderbird\xpcom_core.dll ModLoad: `6d47 `6d477000 C:\Program Files (x86)\Mozilla Thunderbird\plc4.dll ModLoad: `6c85 `6c857000 C:\Program Files (x86)\Mozilla Thunderbird\plds4.dll ModLoad: `767a `773e9000 C:\Windows\syswow64\SHELL32.dll ModLoad: `7600 `76057000 C:\Windows\syswow64\SHLWAPI.dll ModLoad: `7745 `775ac000 C:\Windows\syswow64\ole32.dll ModLoad: `7561 `75619000 C:\Windows\SysWOW64\VERSION.dll ModLoad: `6b4b `6b4c8000 C:\Program Files (x86)\Mozilla Thunderbird\smime3.dll ModLoad: `5f8d `5f96d000 C:\Program Files (x86)\Mozilla Thunderbird\nss3.dll ModLoad: `6b49 `6b4a4000 C:\Program Files (x86)\Mozilla Thunderbird\nssutil3.dll ModLoad: `6b34 `6b361000 C:\Program Files (x86)\Mozilla Thunderbird\ssl3.dll ModLoad: `1000 `10027000 C:\Program Files (x86)\Mozilla Thunderbird\NSLDAP32V60.dll ModLoad: `0002 `00027000 C:\Program Files (x86)\Mozilla Thunderbird\NSLDAPPR32V60.dll ModLoad: `5f85 `5f8cb000 C:\Program Files (x86)\Mozilla Thunderbird\sqlite3.dll ModLoad: `7778 `777fb000 C:\Windows\syswow64\COMDLG32.dll ModLoad: `73b2 `73cbe000 C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16661_none_420fe3fa2b8113bd\COMCTL32.dll ModLoad: `776d `7775f000 C:\Windows\syswow64\OLEAUT32.dll ModLoad: `73ac `73b11000 C:\Win
Re: Thunderbird crashing when C_SignInit returns other than CKR_OK
On 16. 12. 2010 14:02, Nelson Bolyard wrote: On 2010-12-11 11:57 PDT, Matej Kurpel wrote: Ah, that's because I tried CKR_FUNCTION_NOT_SUPPORTED then and copied the wrong pkcs log. But that's not really the point since it crashes everytime, no matter which CKR_ return code I use (apart from CKR_OK) from the ones allowed by the pkcs11 specification. So, you're a developer, developing code to run on windows. I suspect you must have a windows compiler/debugger, such as a free MSVC version. The next step is to use it to get a stack trace of the crash. Even if you don't have full sources, you can still use Mozilla's symbol server to provide the symbols for your stack. Point your debugger's symbols client athttp://symbols.mozilla.org/firefox I have installed the debug package for Windows where WinDbg resides (I didn't have it installed previously). I have set up the symbols url as shown on the web page (with /thunderbird and not /firefox at the end since with /firefox it said it couldn't load the symbols when debugging TB). Then I attached the debugger to a new Thunderbird session. I caused the crash and saw this in the Command window: (164c.1560): C++ EH exception - code e06d7363 (first chance) (164c.1560): C++ EH exception - code e06d7363 (!!! second chance !!!) KERNELBASE!RaiseException+0x58: 7675b727 c9 leave 0:000:x86> g WARNING: Continuing a non-continuable exception (164c.1560): Access violation - code c005 (first chance) First chance exceptions are reported before any exception handling. This exception may be expected and handled. thunderbird!XPCWrappedNative::FinishInit+0x34: 01199547 f60102 testbyte ptr [ecx],2 ds:002b:00090109=?? When pressing F5, the access violation always repeated. And in the Calls window (I guess this is the stack trace you were writing about): # ChildEBP RetAddr Args to Child 00 0027e3f8 01199e98 0027e92c 019f721c 6b882629 thunderbird!XPCWrappedNative::FinishInit(class XPCCallContext * ccx = 0x0119b8ac)+0x34 (FPO: [1,0,0]) (CONV: thiscall) [e:\buildbot\win32_build_31\build\mozilla\js\src\xpconnect\src\xpcwrappednative.cpp @ 1191] 01 0027e410 0119b8ac 0027e92c 05f5f0c0 thunderbird!XPCWrappedNative::Init(class XPCCallContext * ccx = 0x0027e92c, struct JSObject * parent = 0x05f5f0c0, int isGlobal = 0n0, class XPCNativeScriptableCreateInfo * sci = 0x0027e4a4)+0xeb (FPO: [Non-Fpo]) (CONV: thiscall) [e:\buildbot\win32_build_31\build\mozilla\js\src\xpconnect\src\xpcwrappednative.cpp @ 1141] 02 0027e4c8 0119da26 0027e92c 08d93ce4 05f5b640 thunderbird!XPCWrappedNative::GetNewOrUsed(class XPCCallContext * ccx = 0x0027e92c, class nsISupports * Object = 0x08d93ce4, class XPCWrappedNativeScope * Scope = 0x05f5b640, class XPCNativeInterface * Interface = 0x0a7efee0, class nsWrapperCache * cache = 0x, int isGlobal = 0n0, class XPCWrappedNative ** resultWrapper = 0x0027e54c)+0x60c (FPO: [Non-Fpo]) (CONV: cdecl) [e:\buildbot\win32_build_31\build\mozilla\js\src\xpconnect\src\xpcwrappednative.cpp @ 571] 03 0027e550 0119e4fd 0027e5c8 0027e794 thunderbird!XPCConvert::NativeInterface2JSObject(class XPCLazyCallContext * lccx = 0x0027e5c8, int * d = 0x0027e794, class nsIXPConnectJSObjectHolder ** dest = 0x, class nsISupports * src = 0x08d93ce4, struct nsID * iid = 0x0027e858, class XPCNativeInterface ** Interface = 0x, class nsWrapperCache * cache = 0x, struct JSObject * scope = 0x08d9ddc0, int allowNativeWrapper = 0n1, int isGlobal = 0n0, unsigned int * pErr = 0x0027e77c)+0x199 (FPO: [Non-Fpo]) (CONV: cdecl) [e:\buildbot\win32_build_31\build\mozilla\js\src\xpconnect\src\xpcconvert.cpp @ 1199] 04 0027e594 0119849b 0027e5c8 0027e794 0027e6c4 thunderbird!XPCConvert::NativeData2JS(class XPCLazyCallContext * lccx = 0x0027e5c8, int * d = 0x0027e794, void * s = 0x0027e6c4, class nsXPTType * type = 0x0027e79f, struct nsID * iid = 0x0027e858, struct JSObject * scope = 0x08d9ddc0, unsigned int * pErr = 0x0027e77c)+0x314 (FPO: [Non-Fpo]) (CONV: cdecl) [e:\buildbot\win32_build_31\build\mozilla\js\src\xpconnect\src\xpcconvert.cpp @ 471] 05 0027e684 0119abbf 0027e92c 0027e794 0027e6c4 thunderbird!XPCConvert::NativeData2JS(class XPCCallContext * ccx = 0x0027e92c, int * d = 0x0027e794, void * s = 0x0027e6c4, class nsXPTType * type = 0x0027e79f, struct nsID * iid = 0x0027e858, struct JSObject * scope = 0x08d9ddc0, unsigned int * pErr = 0x0027e77c)+0x4c (FPO: [Non-Fpo]) (CONV: cdecl) [e:\buildbot\win32_build_31\build\mozilla\js\src\xpconnect\src\xpcprivate.h @ 2985] 06 0027e900 011a122b 0027e92c 00a83c00 thunderbird!XPCWrappedNative::CallMethod(class XPCCallContext * ccx = 0x0027e92c, XPCWrappedNative::CallMode mode = CALL_METHOD (0n0))+0xcec (FPO: [Non-Fpo]) (CONV: cdecl) [e:\buildbot\win32_build_31\build\mozilla\js\src\xpconnect\src\xpcwrappednative.cpp @ 2810] 07 0027e9c4 6ba05afd 00a83c00 08d9ddc0 000
Re: Thunderbird crashing when C_SignInit returns other than CKR_OK
On 11. 12. 2010 19:05, Nelson B Bolyard wrote: Matej, Your message contains an obvious self-contradiction. Observe: On 2010-12-10 09:57 PDT, Matej Kurpel wrote: CK_RV CK_ENTRY C_SignInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) { return CKR_FUNCTION_CANCELED;<<<<<<<<<<<<<<<<<< } 89: C_SignInit [in] hSession = 0x2 pMechanism->type=CKM_RSA_PKCS [in] hKey = 0x2 Returned: 84 CKR_FUNCTION_NOT_SUPPORTED<<<<<<<<<<<<<<<<<< Are you perhaps not testing with your own latest builds, or something? Ah, that's because I tried CKR_FUNCTION_NOT_SUPPORTED then and copied the wrong pkcs log. But that's not really the point since it crashes everytime, no matter which CKR_ return code I use (apart from CKR_OK) from the ones allowed by the pkcs11 specification. M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Thunderbird crashing when C_SignInit returns other than CKR_OK
Hello, I am implementing a PKCS#11 module. I would like to implement authentication on my device (using a pin-pad) everytime a signature is requested from it. The idea is that on C_SignInit, I ask the user for the PIN and if the PIN is incorrect (or user has cancelled for whatever reason), it should return CKR_FUNCTION_CANCELED. Now I am facing a problem with Thunderbird. I choose to compose a new message and let it be signed (of course, I provide an invalid PIN to my device deliberately). The first time Thunderbird just pops up an error message that it was unable to sign - and that is fine. However, when I try to send the message again (and it is going to get signed again), Thunderbird crashes/acts in a weird way. Sometimes it wants to send a bug report to Mozilla, but most of the time it ends up with a C++ runtime error and an empty little window behind the error message (screenshot 2). Sometimes it hangs on "Creating mail message..." (with the progress bar moving) and a little empty window behind it (screenshot 1). Screenshot 1: http://img6.glowfoto.com/images/2010/12/10-0954327898L.png Screenshot 2: http://img4.glowfoto.com/images/2010/12/10-1150202661L.png I have eliminated bugs on my side by returning CKR_FUNCTION_CANCELED straight from my DLL module as follows: CK_RV CK_ENTRY C_SignInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) { return CKR_FUNCTION_CANCELED; } In my pkcs11spy-log everything looks normal (as when it's working): 88: C_OpenSession [in] slotID = 0x0 [in] flags = 0x4 pApplication=065F4000 Notify=6004A378 [out] *phSession = 0x2 Returned: 0 CKR_OK 89: C_SignInit [in] hSession = 0x2 pMechanism->type=CKM_RSA_PKCS [in] hKey = 0x2 Returned: 84 CKR_FUNCTION_NOT_SUPPORTED 90: C_CloseSession [in] hSession = 0x2 Returned: 0 CKR_OK Before this, I tried to do the same in C_Sign (not C_SignInit) but it crashed as well. I thought that I did it wrong and it should be right in C_SignInit but it seems I was wrong again. Looks like a bug in Thunderbird to me, but if anyone has any ideas on how to circumvent it (or maybe I am doing a mistake somewhere), please let me know. Thanks in advance. M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Certificate login in Firefox - how does it work?
On 28. 11. 2010 17:24, Matej Kurpel wrote: On 26. 11. 2010 22:20, ryan-mozdevtechcry...@sleevi.com wrote: -Original Message- Sent: Friday, November 26, 2010 3:16 PM To: mozilla's crypto code discussion list Subject: Certificate login in Firefox - how does it work? Hello, I am developing a PKCS#11 module and currently I am having problems getting the certificate login working in Firefox. I load a page, click on login button and then Firefox starts communicating with my PKCS#11 module (the page wants its users to log in using their certificates). It lets me select a certificate from a list - well, I only have one so I select it and continue. Then, after some more communication, C_Sign is performed. However, this fails because I have no way of dealing with the data Firefox sends to my PKCS#11 module (the data to sign using the C_Sign function). Signing works properly in Thunderbird since it sends DER-encoded data (hash algorithm OID and the hash itself) and dealing with that is fairly straightforward. However, Firefox sends some seemingly-random 36-byte data. If I use the same algorithm as for Thunderbird (doesn't matter if SHA1 or MD5), the page fails to load and says "ssl_error_decrypt_error_alert". I don't know what should my PKCS#11 module provide for the page to accept it correctly and continue. Just FYI, there is a C# .NET program on the other end and trying SignData or SignHash to compute the value to return proved unsuccessful. Please, could anybody enlighten this issue to me? Please see the TLS 1.0 RFC, Section 7.4.8. Certificate Verify [1] (or later, but TLS 1.0 is appropriate for the current release of NSS) The handshake of a TLS 1.0 client using an RSA key is the concatenation of the SHA-1 and MD-5 hashes of the handshake messages exchanged since the Client Hello. If you're mapping this to CryptoAPI types (since you mentioned C#, I'm presuming some Windows& CryptoAPI familiarity), this is CALG_SSL3_SHAMD5 [2]. The 36 bytes comes from the size of MD5 (16 bytes) and SHA-1 (20 bytes). For other key types (eg: DSA, ECC), and depending on whether you're acting as a server or a client, the signature data may differ, see the appropriate RFCs (ie: [3]) The actual call is made as part of ssl3_SignHashes, assuming you're using SSL 3.0/TLS 1.0. If you're using SSL 2.0, you've got more problems than hash signing. The implementation of this method is at [4]. I don't know what the page is actually using (I don't have it under my control). How can I determine it? While I've not spent time hacking with PCKS#11, my understanding is that the C_Sign function should be treating the input as raw/opaque, dictated by the mechanism that was used to initialize. If you're relying on the input being in a particular format, you need to ensure that format is specified in the underlying PKCS#11 specification for that mechanism, otherwise it sounds like you're making assumptions that shouldn't be made. This assumption is made by NSS and not by me. When signing e-mail in Thunderbird, it sends DigestInfo (with DER-encoded OID and Hash value), and when performing a SSL login, it sends raw data. The mechanism used is always CKM_RSA_PKCS. I don't have a bulletproof way to determine which of these two cases it is. For SSL/TLS signatures, and for RSA keys, the mechanism passed is CKM_RSA_PKCS [5]. According to the PKCS#11 specification, this mechanism corresponds to computing the raw RSA signature over data, *excluding* computing the message digest or DigestInfo structure [6]. In CryptoAPI terms, this is the option CRYPT_NOHASHOID [7]. For what it's worth, I'm not aware of this flag being exposed by the .NET implementation, eg: System.Security.Cryptography.RSACryptoServiceProvider's SignHash. You'll likely need to do some marshalling to the native APIs if you're using C#. Yes, I think so too. But I am not familiar with WinAPI and the source codes in MSDN look really terrible. Also I don't use CryptoAPI, I manage my certificates and keys myself in my C# .NET program and use RSACryptoServiceProvider for the cryptographic operations. So I have access to raw key and certificate data, I don't want to mess with all the CryptoAPI things. I think it would involve more than just marshalling, I would have to make my own C++ dll file which would perform such operations and then marshal data between it and my C# program. I have tried it before with something else and it didn't work as expected... The second thing is that the C# .NET program I am talking about is actually .NET CF program which is run on a Windows Mobile system. The .NET CF framework is somewhat crippled of some features so I really don't know if the API functions described in MSDN are available. And to save you a bit of trouble/pain: for CryptoAPI, you cannot simply sign raw data
Re: Certificate login in Firefox - how does it work?
On 26. 11. 2010 22:20, ryan-mozdevtechcry...@sleevi.com wrote: -Original Message- Sent: Friday, November 26, 2010 3:16 PM To: mozilla's crypto code discussion list Subject: Certificate login in Firefox - how does it work? Hello, I am developing a PKCS#11 module and currently I am having problems getting the certificate login working in Firefox. I load a page, click on login button and then Firefox starts communicating with my PKCS#11 module (the page wants its users to log in using their certificates). It lets me select a certificate from a list - well, I only have one so I select it and continue. Then, after some more communication, C_Sign is performed. However, this fails because I have no way of dealing with the data Firefox sends to my PKCS#11 module (the data to sign using the C_Sign function). Signing works properly in Thunderbird since it sends DER-encoded data (hash algorithm OID and the hash itself) and dealing with that is fairly straightforward. However, Firefox sends some seemingly-random 36-byte data. If I use the same algorithm as for Thunderbird (doesn't matter if SHA1 or MD5), the page fails to load and says "ssl_error_decrypt_error_alert". I don't know what should my PKCS#11 module provide for the page to accept it correctly and continue. Just FYI, there is a C# .NET program on the other end and trying SignData or SignHash to compute the value to return proved unsuccessful. Please, could anybody enlighten this issue to me? Please see the TLS 1.0 RFC, Section 7.4.8. Certificate Verify [1] (or later, but TLS 1.0 is appropriate for the current release of NSS) The handshake of a TLS 1.0 client using an RSA key is the concatenation of the SHA-1 and MD-5 hashes of the handshake messages exchanged since the Client Hello. If you're mapping this to CryptoAPI types (since you mentioned C#, I'm presuming some Windows& CryptoAPI familiarity), this is CALG_SSL3_SHAMD5 [2]. The 36 bytes comes from the size of MD5 (16 bytes) and SHA-1 (20 bytes). For other key types (eg: DSA, ECC), and depending on whether you're acting as a server or a client, the signature data may differ, see the appropriate RFCs (ie: [3]) The actual call is made as part of ssl3_SignHashes, assuming you're using SSL 3.0/TLS 1.0. If you're using SSL 2.0, you've got more problems than hash signing. The implementation of this method is at [4]. I don't know what the page is actually using (I don't have it under my control). How can I determine it? While I've not spent time hacking with PCKS#11, my understanding is that the C_Sign function should be treating the input as raw/opaque, dictated by the mechanism that was used to initialize. If you're relying on the input being in a particular format, you need to ensure that format is specified in the underlying PKCS#11 specification for that mechanism, otherwise it sounds like you're making assumptions that shouldn't be made. This assumption is made by NSS and not by me. When signing e-mail in Thunderbird, it sends DigestInfo (with DER-encoded OID and Hash value), and when performing a SSL login, it sends raw data. The mechanism used is always CKM_RSA_PKCS. I don't have a bulletproof way to determine which of these two cases it is. For SSL/TLS signatures, and for RSA keys, the mechanism passed is CKM_RSA_PKCS [5]. According to the PKCS#11 specification, this mechanism corresponds to computing the raw RSA signature over data, *excluding* computing the message digest or DigestInfo structure [6]. In CryptoAPI terms, this is the option CRYPT_NOHASHOID [7]. For what it's worth, I'm not aware of this flag being exposed by the .NET implementation, eg: System.Security.Cryptography.RSACryptoServiceProvider's SignHash. You'll likely need to do some marshalling to the native APIs if you're using C#. Yes, I think so too. But I am not familiar with WinAPI and the source codes in MSDN look really terrible. Also I don't use CryptoAPI, I manage my certificates and keys myself in my C# .NET program and use RSACryptoServiceProvider for the cryptographic operations. So I have access to raw key and certificate data, I don't want to mess with all the CryptoAPI things. I think it would involve more than just marshalling, I would have to make my own C++ dll file which would perform such operations and then marshal data between it and my C# program. I have tried it before with something else and it didn't work as expected... The second thing is that the C# .NET program I am talking about is actually .NET CF program which is run on a Windows Mobile system. The .NET CF framework is somewhat crippled of some features so I really don't know if the API functions described in MSDN are available. And to save you a bit of trouble/pain: for CryptoAPI, you cannot simply sign raw data - you can only sign previously hashed data. I understand this to mean that you cannot write a pure PKCS#11 -> CryptoAPI mapper, whether .NET or at the raw Win32 level, because the Crypto
Certificate login in Firefox - how does it work?
Hello, I am developing a PKCS#11 module and currently I am having problems getting the certificate login working in Firefox. I load a page, click on login button and then Firefox starts communicating with my PKCS#11 module (the page wants its users to log in using their certificates). It lets me select a certificate from a list - well, I only have one so I select it and continue. Then, after some more communication, C_Sign is performed. However, this fails because I have no way of dealing with the data Firefox sends to my PKCS#11 module (the data to sign using the C_Sign function). Signing works properly in Thunderbird since it sends DER-encoded data (hash algorithm OID and the hash itself) and dealing with that is fairly straightforward. However, Firefox sends some seemingly-random 36-byte data. If I use the same algorithm as for Thunderbird (doesn't matter if SHA1 or MD5), the page fails to load and says "ssl_error_decrypt_error_alert". I don't know what should my PKCS#11 module provide for the page to accept it correctly and continue. Just FYI, there is a C# .NET program on the other end and trying SignData or SignHash to compute the value to return proved unsuccessful. Please, could anybody enlighten this issue to me? -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Firefox forgets to C_CloseAllSessions and C_Finalize when closing it
On 16. 11. 2010 14:53, Matej Kurpel wrote: Hello, I am implementing a PKCS#11 module and have just implemented C_GenerateKeyPair. For this purpose, I have set up a html page with the "keygen" tag which sends the form data to my php script to write back to me what was sent. Now, everything works perfectly. It generates the key pair, then sets the CKA_ID attribute of both keys, asks for some more attributes, then it signs some md5 hashed data with the newly generated private key and closes the session. Lastly, C_GetAttributeValue is called to see if the public key (handle 0x03) is a token object. It indeed is so I provide the value. The problem is, that is the last thing Firefox does. When closing it, it forgets to call C_CloseAllSessions and then C_Finalize, as Thunderbird does. So the next time I open Firefox, C_Initialize is called again which creates a new state in the device, thus leaving dangling resources by the old, unused "session". Is this a bug or am I missing something? I am attaching a pkcs11-spy log (with unneccessary info stripped out) if it is needed. Thanks in advance, M. Kurpel - pkcs11-spy log begin -- 7: C_GetMechanismList [in] slotID = 0x0 [out] pMechanismList[2]: Count is 2 Returned: 0 CKR_OK 8: C_GetMechanismList [in] slotID = 0x0 [out] pMechanismList[2]: CKM_RSA_PKCS CKM_RSA_PKCS_KEY_PAIR_GEN Returned: 0 CKR_OK 9: C_OpenSession [in] slotID = 0x0 [in] flags = 0x4 pApplication=06CA5400 Notify=5D5EA378 [out] *phSession = 0x1 Returned: 0 CKR_OK 10: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[1]: CKA_CLASS CKO_NETSCAPE_BUILTIN_ROOT_LIST Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 11: C_GetMechanismInfo [in] slotID = 0x0 CKM_RSA_PKCS [out] pInfo: CKM_RSA_PKCS : min:256 max:4096 flags:0xA01 Returned: 0 CKR_OK 12: C_OpenSession [in] slotID = 0x0 [in] flags = 0x6 pApplication=06CA5400 Notify=5D5EA378 [out] *phSession = 0x2 Returned: 0 CKR_OK 13: C_GenerateKeyPair [in] hSession = 0x2 pMechanism->type=CKM_RSA_PKCS_KEY_PAIR_GEN [in] pPublicKeyTemplate[8]: CKA_MODULUS_BITS [size : 0x4 (4)] 0004 CKA_PUBLIC_EXPONENT [size : 0x3 (3)] 010001 CKA_TOKEN True CKA_DERIVEFalse CKA_WRAP False CKA_VERIFYFalse CKA_VERIFY_RECOVERFalse CKA_ENCRYPT False [in] pPrivateKeyTemplate[7]: CKA_TOKEN True CKA_PRIVATE True CKA_SENSITIVE True CKA_DERIVEFalse CKA_UNWRAPFalse CKA_SIGN True CKA_DECRYPT True [out] hPublicKey = 0x3 [out] hPrivateKey = 0x4 Returned: 0 CKR_OK 14: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x3 [in] pTemplate[1]: CKA_CLASS requested with 4 buffer [out] pTemplate[1]: CKA_CLASS CKO_PUBLIC_KEY Returned: 0 CKR_OK 15: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x3 [in] pTemplate[4]: CKA_CLASS requested with 4 buffer CKA_KEY_TYPE requested with 4 buffer CKA_MODULUS requested with 0 buffer CKA_PUBLIC_EXPONENT requested with 0 buffer [out] pTemplate[4]: CKA_CLASS CKO_PUBLIC_KEY CKA_KEY_TYPE CKK_RSA CKA_MODULUS has size 128 CKA_PUBLIC_EXPONENT has size 3 Returned: 0 CKR_OK 16: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x3 [in] pTemplate[4]: CKA_CLASS requested with 4 buffer CKA_KEY_TYPE requested with 4 buffer CKA_MODULUS requested with 128 buffer CKA_PUBLIC_EXPONENT requested with 3 buffer [out] pTemplate[4]: CKA_CLASS CKO_PUBLIC_KEY CKA_KEY_TYPE CKK_RSA CKA_MODULUS [size : 0x80 (128)] B3906CBA 83B28918 CDC1EFB3 E4A93367 CF6C0674 6A40ED7E 1758DFDE C740AA97 FD6AE7F7 033BA8FE 3329BDBE 2AA00242 7CA82A47 F6B5E15F AC16400F 35D5033E 28B4BA6B 67C35BB2 A49A9CD9 1CC701EF 0984CE38 34ABAA5E 01F92EA2 0488C3AE E48A7C4B 01667D1C 4FFAE1D2 3A86CAEB 64489E1B 01456657 249E9593 3C2B5D95 CKA_PUBLIC_EXPONENT [size : 0x3 (3)] 010001 Returned: 0 CKR_OK 17: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x3 [in] pTemplate[1]: CKA_TOKEN requested with 1 buffer [out] pTemplate[1]: CKA_TOKEN True Returned: 0 CKR_OK 18: C_SetAttributeValue [in] hSession = 0x2 [in] hObject = 0x4 [in] pTemplate[1]: CKA_ID[size : 0x14 (20)] FEA653BE 4BD2BD65 272F2102 49833397 3AB3F67B Returned: 0 CKR_OK 19: C_SetAttributeValue [in] hSession = 0x2 [in] hObject = 0x3 [in] pTemplate[1]: CKA_ID[size : 0x14 (20)] FEA653BE 4BD2BD65 272F2102 49833397 3AB3F67B Returned: 0 CKR_OK 20: C_CloseSession [in] hSession = 0x2 Returned: 0 CKR_OK 21: C_GetAttributeValue [in] hSession = 0x1
Firefox forgets to C_CloseAllSessions and C_Finalize when closing it
Hello, I am implementing a PKCS#11 module and have just implemented C_GenerateKeyPair. For this purpose, I have set up a html page with the "keygen" tag which sends the form data to my php script to write back to me what was sent. Now, everything works perfectly. It generates the key pair, then sets the CKA_ID attribute of both keys, asks for some more attributes, then it signs some md5 hashed data with the newly generated private key and closes the session. Lastly, C_GetAttributeValue is called to see if the public key (handle 0x03) is a token object. It indeed is so I provide the value. The problem is, that is the last thing Firefox does. When closing it, it forgets to call C_CloseAllSessions and then C_Finalize, as Thunderbird does. So the next time I open Firefox, C_Initialize fails because the device is already initialized. Is this a bug or am I missing something? I am attaching a pkcs11-spy log (with unneccessary info stripped out) if it is needed. Thanks in advance, M. Kurpel - pkcs11-spy log begin -- 7: C_GetMechanismList [in] slotID = 0x0 [out] pMechanismList[2]: Count is 2 Returned: 0 CKR_OK 8: C_GetMechanismList [in] slotID = 0x0 [out] pMechanismList[2]: CKM_RSA_PKCS CKM_RSA_PKCS_KEY_PAIR_GEN Returned: 0 CKR_OK 9: C_OpenSession [in] slotID = 0x0 [in] flags = 0x4 pApplication=06CA5400 Notify=5D5EA378 [out] *phSession = 0x1 Returned: 0 CKR_OK 10: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[1]: CKA_CLASS CKO_NETSCAPE_BUILTIN_ROOT_LIST Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 11: C_GetMechanismInfo [in] slotID = 0x0 CKM_RSA_PKCS [out] pInfo: CKM_RSA_PKCS : min:256 max:4096 flags:0xA01 Returned: 0 CKR_OK 12: C_OpenSession [in] slotID = 0x0 [in] flags = 0x6 pApplication=06CA5400 Notify=5D5EA378 [out] *phSession = 0x2 Returned: 0 CKR_OK 13: C_GenerateKeyPair [in] hSession = 0x2 pMechanism->type=CKM_RSA_PKCS_KEY_PAIR_GEN [in] pPublicKeyTemplate[8]: CKA_MODULUS_BITS [size : 0x4 (4)] 0004 CKA_PUBLIC_EXPONENT [size : 0x3 (3)] 010001 CKA_TOKEN True CKA_DERIVEFalse CKA_WRAP False CKA_VERIFYFalse CKA_VERIFY_RECOVERFalse CKA_ENCRYPT False [in] pPrivateKeyTemplate[7]: CKA_TOKEN True CKA_PRIVATE True CKA_SENSITIVE True CKA_DERIVEFalse CKA_UNWRAPFalse CKA_SIGN True CKA_DECRYPT True [out] hPublicKey = 0x3 [out] hPrivateKey = 0x4 Returned: 0 CKR_OK 14: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x3 [in] pTemplate[1]: CKA_CLASS requested with 4 buffer [out] pTemplate[1]: CKA_CLASS CKO_PUBLIC_KEY Returned: 0 CKR_OK 15: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x3 [in] pTemplate[4]: CKA_CLASS requested with 4 buffer CKA_KEY_TYPE requested with 4 buffer CKA_MODULUS requested with 0 buffer CKA_PUBLIC_EXPONENT requested with 0 buffer [out] pTemplate[4]: CKA_CLASS CKO_PUBLIC_KEY CKA_KEY_TYPE CKK_RSA CKA_MODULUS has size 128 CKA_PUBLIC_EXPONENT has size 3 Returned: 0 CKR_OK 16: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x3 [in] pTemplate[4]: CKA_CLASS requested with 4 buffer CKA_KEY_TYPE requested with 4 buffer CKA_MODULUS requested with 128 buffer CKA_PUBLIC_EXPONENT requested with 3 buffer [out] pTemplate[4]: CKA_CLASS CKO_PUBLIC_KEY CKA_KEY_TYPE CKK_RSA CKA_MODULUS [size : 0x80 (128)] B3906CBA 83B28918 CDC1EFB3 E4A93367 CF6C0674 6A40ED7E 1758DFDE C740AA97 FD6AE7F7 033BA8FE 3329BDBE 2AA00242 7CA82A47 F6B5E15F AC16400F 35D5033E 28B4BA6B 67C35BB2 A49A9CD9 1CC701EF 0984CE38 34ABAA5E 01F92EA2 0488C3AE E48A7C4B 01667D1C 4FFAE1D2 3A86CAEB 64489E1B 01456657 249E9593 3C2B5D95 CKA_PUBLIC_EXPONENT [size : 0x3 (3)] 010001 Returned: 0 CKR_OK 17: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x3 [in] pTemplate[1]: CKA_TOKEN requested with 1 buffer [out] pTemplate[1]: CKA_TOKEN True Returned: 0 CKR_OK 18: C_SetAttributeValue [in] hSession = 0x2 [in] hObject = 0x4 [in] pTemplate[1]: CKA_ID[size : 0x14 (20)] FEA653BE 4BD2BD65 272F2102 49833397 3AB3F67B Returned: 0 CKR_OK 19: C_SetAttributeValue [in] hSession = 0x2 [in] hObject = 0x3 [in] pTemplate[1]: CKA_ID[size : 0x14 (20)] FEA653BE 4BD2BD65 272F2102 49833397 3AB3F67B Returned: 0 CKR_OK 20: C_CloseSession [in] hSession = 0x2 Returned: 0 CKR_OK 21: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x4 [in] pTemplate[1]: CKA_PRIVATE requested with 1 buffer [out] pTemplate[1]: CKA_PRIVATE True Returned: 0
C_Initialize CKR_CRYPTOKI_ALREADY_INITIALIZED
Hello, I am developing a PKCS#11 module and stumbled upon a confusion as how to manage multiple applications calling Cryptoki calls. I can't seem to get an answer by reading the PKCS#11 specification, nor by googling, so I am asking you :) Currently, I have a boolean flag indicating whether C_Initialize has been called. It is set to true in call to C_Initialize, and back to false in C_Finalize. Now, when I load my module into Firefox, it calls C_Initialize upon its start and C_Finalize when closing the last window. But when I launch Thunderbird (with the module loaded as well) while Firefox is already running, it calls C_Initialize, and, obviously fails with CKR_CRYPTOKI_ALREADY_INITIALIZED. From what I understood from the specification, access to a Cryptoki library should be permitted for more applications simultaneously. The problem is, I don't have any form of application identification on C_Initialize; only on C_OpenSession (the pApplication pointer). If I am to implement application identification on C_OpenSession, then when is C_Initialize supposed to return CKR_CRYPTOKI_ALREADY_INITIALIZED and when CKR_OK? I don't have a way of knowing if it's the same or new application trying to initalize the library. Any clues, please? M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Thunderbird can decrypt without private key?
Hello, I am implementing a PKCS#11 module for Thunderbird and I have stuck upon a weird behavior of Thunderbird. Let me explain: For the purposes of testing, I have created a second gmail account. I have also generated the keys and certificate for this account but only imported its certificate into Thunderbird (under the "People" tab in Certificate Manager) - I did that in order to be able to send encrypted messages from my primary account to this secondary account. I have my certificate and private key (for the primary account) in my token and all is properly configured in Thunderbird. Now, when I send an encrypted e-mail from my primary account to my secondary account and then try to read it (when it arrives), Thunderbird is able to decrypt it for me. I don't understand why, shouldn't that fail? I didn't give it the private key for the secondary account anywhere. From the pkcs11-spy log I can see it's calling C_DecryptInit and C_Decrypt as follows: 66: C_DecryptInit [in] hSession = 0x2 pMechanism->type=CKM_RSA_PKCS [in] hKey = 0x2 Returned: 0 CKR_OK 67: C_Decrypt [in] hSession = 0x2 [in] pEncryptedData[ulEncryptedDataLen] [size : 0x80 (128)] 4559BE33 DE12B7F1 72909126 F9F16537 8638661F 588BBCDE 2B8E2180 BC0E83BA AC1A26C0 67A25DF0 7560B64F E3E726A5 09640A4E 47540E4A D5FE2A76 2116E61E 783EC37A 5600ED67 E42988E5 D419AC4E 70395E7F 1D0FCA66 70049230 D61E698F F6DDB51B EC79FD78 68B880F6 80A3748E F874EBA9 A672C251 003B0339 E7D8384E [out] pData[*pulDataLen] [size : 0x18 (24)] 673DB607 4ABCB3E0 431A9E0D 1991BC1C DCBC0208 70076D8C Returned: 0 CKR_OK What I have learned from this mailing list in the past is that Thunderbird is trying to implement key unwrapping by calling C_DecryptInit and C_Decrypt (and apparently this is what's actually happening). However, for the unwrapping, it should use the private key for the secondary account which it doesn't have, right? Instead, it uses the private key for the primary account (hKey = 0x2) and, surprisingly, succeedes...? Please shed some light on this for me, if you know why it behaves like this. M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Thunderbird UnwrapKey on message decryption?
Hello, I am implementing a PKCS#11 module. Today I tried to send encrypted e-mail to my second gmail account, and it works perfectly (in fact, nothing is needed from my token to support this). However, when the message arrives and I try to read it, Thunderbird calls C_UnwrapKey (which, of course, I don't have implemented) and then C_DecryptInit (I will implement this in the near future). So it's OK that the decryption fails. But, why does TB need to unwrap some key? What is this key and where does it come from? It's trying to unwrap that key no matter what, despite the fact that the key for unwrapping has CKA_UNWRAP set to FALSE, the mechanism doesn't have its CKF_UNWRAP flag set and the token is read only. Is this a bug of some sort? (I am attaching the pkcs11-spy log) 78: C_GetMechanismInfo [in] slotID = 0x0 CKM_RSA_PKCS [out] pInfo: CKM_RSA_PKCS : min:256 max:4096 flags:0xA01 Returned: 0 CKR_OK ... ... 83: C_UnwrapKey [in] hSession = 0x2 pMechanism->type=CKM_RSA_PKCS [in] hUnwrappingKey = 0x2 [in] pWrappedKey[ulWrappedKeyLen] [size : 0x80 (128)] A19820CD 6DC92728 62A54066 7F06ABFD 33164AB2 2B8FD6AE D16BF51B 0610038F 766ACC79 464A7097 36254469 AB6F0508 3D96F701 244C86B9 8E7DD4B8 E6BF5679 2EF5FA9D F70E0205 CAC8D16F 650F2D55 C4ACF796 549AA9A4 5CDFD506 29F7916C D47E83A2 B9C58030 C975802E 2584D6CC 7D08C6C3 4A4FBFBB 26463FBA FC010C37 [in] pTemplate[3]: CKA_CLASS CKO_SECRET_KEY CKA_KEY_TYPE CKK_DES3 CKA_DECRYPT True Returned: 226 CKR_TOKEN_WRITE_PROTECTED M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
pk11util
Hello, I would like to get my hands on pk11util to check my PKCS#11 module for conformance to said standard (my search on the net yielded that pk11util is suitable for this purpose). However, the precompiled NSS for windows does not contain this utility. I have tried to compile it myself (yes, again and again) but after a few hours of trial-and-error I simply gave up. Could someone please point me to a place where I could download pk11util.exe ready to use? My google search came up with nothing useful. Or suggest some other utility to perform checks for PKCS#11 standard conformance (something like W3C's markup validator, heh). Thanks, M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Invalide certificate encoding crashing certutil [Re: Thunderbird: "Could not verify this certificate for unknown reasons"]
On 29. 10. 2010 14:11, Nelson B Bolyard wrote: On 2010/10/28 02:14 PDT, Jean-Marc Desperrier wrote: Nelson B Bolyard wrote: Please don't file a bug without a stack trace showing the crash is in NSS. [...] If the back trace shows the crash is not in NSS, but in some other library, please direct the bug report accordingly. The report is that the crashs is inside NSS's certutil, Nelson. Perhaps I have confused this Matej with another. I understood that Matej is developing his own PKCS#11 module, and his report is that NSS's certutil crashes when run with his non-NSS PKCS#11 module. The crash may well be in that module. Matej, If I'm confused, feel free to set me straight. You are right, Nelson. M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Invalide certificate encoding crashing certutil [Re: Thunderbird: "Could not verify this certificate for unknown reasons"]
On 28. 10. 2010 11:14, Jean-Marc Desperrier wrote: Nelson B Bolyard wrote: Please don't file a bug without a stack trace showing the crash is in NSS. [...] If the back trace shows the crash is not in NSS, but in some other library, please direct the bug report accordingly. The report is that the crashs is inside NSS's certutil, Nelson. As Thunderbird with the same data doesn't crash, it doesn't seem to actually be in the library, but even just in a NSS tool, a crash is serious. I would like to file the bug if I had a way to actually obtain the stack trace. I guess I need to compile a debug version of certutil myself, but again, I failed doing that and I found no answer to the errors I was getting from cl.exe. I don't want to get headache again from all the C++ stuff which doesn't work as it should when it comes to compilation. M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Invalide certificate encoding crashing certutil [Re: Thunderbird: "Could not verify this certificate for unknown reasons"]
On 26. 10. 2010 10:43, Jean-Marc Desperrier wrote: Matej Kurpel wrote: In the Type field for S:, O:, OU: and CN: I always provided 0x0c which is utf-8 string, but in the certificate there was 0x13 - printable string. After I changed it - voila, it's working in Thunderbird, and certutil doesn't crash anymore. It sounds like a serious bug. Could you open it in bugzilla, with NSS tools as the component ? Just to recap: it was my fault that I provided the wrong Type fields - other ones than those that were physically in the certificate. In the CKA_VALUE I provided all certificate bytes and in CKA_ISSUER and CKA_SUBJECT I provided my own DER-encoded values with the wrong Type fields. However, how does a printable string differ from utf8string (and other strings, particularly ia5string) when there are no non-ascii characters? Do you think it's a bug in NSS...? M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Thunderbird: "Could not verify this certificate for unknown reasons"
On 25. 10. 2010 12:16, Matej Kurpel wrote: On 24. 10. 2010 20:59, Nelson B Bolyard wrote: On 2010-10-24 02:12 PDT, Matej Kurpel wrote: [snip] You can clearly see both my CA and user certificates. Certutil has used my PKCS#11 module to obtain my user certificate. Then I launched the second commany you were suggesting: certutil -d . -L -n "HTC Touch HD T8282:Matej Kurpel" Now it popped up a message that certutil.exe has stopped working. From my PKCS11-spy logs it's apparent that it searched for the certificate, found it, got some of its atttributes, and then searched for a private key belonging to this certificate (and found it): FindObjectsInit - FindObjects - FindObjectsFinal. That's all it did and then crashed. Looks like something is wrong with my certificate but how can I check it when certutil is crashing? Maybe something is wrong with your PKCS#11 module, or maybe something is wrong with certutil. What does the stack backtrace from the crash show you? Hey, excuse my n00b-ness :) but I don't know how to get the stack trace. I wanted to create the certutil project in VC++ and compile and debug it there but I couldn't find a header file "prcpucfg.h" which, according to google, had yet to be generated by make (grrr...). So I went to compile NSS myself. I did everything according to this page: http://www.mozilla.org/projects/security/pki/nss/buildnss_32.html But after launching the final step, "gmake nss_build_all", all I get are some errors: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. cl : Command line warning D9002 : ignoring unknown option '-ne' cl : Command line warning D9024 : unrecognized source file type '2>&1', object f ile assumed cl : Command line warning D9024 : unrecognized source file type '|', object file assumed cl : Command line warning D9024 : unrecognized source file type 'sed', object fi le assumed cl : Command line warning D9024 : unrecognized source file type 's|.* \([0-9]\+\ .[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p', object file assumed gmake: *** No rule to make target `ns_build_all'. Stop. Google provides no solutions. I am starting to tear my hair out when it comes to these annoying trouble with compiling and all the C/C++ stuff, when nothing works as it should. Please help me :( M. Kurpel Aaah, well... Now in the evening I looked at the certificate in binary and my issuer and subject der-output from the token and there were differences. In the Type field for S:, O:, OU: and CN: I always provided 0x0c which is utf-8 string, but in the certificate there was 0x13 - printable string. After I changed it - voila, it's working in Thunderbird, and certutil doesn't crash anymore. Thanks for your willing to help, Nelson, it's really appreciated. M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Thunderbird: "Could not verify this certificate for unknown reasons"
On 24. 10. 2010 20:59, Nelson B Bolyard wrote: On 2010-10-24 02:12 PDT, Matej Kurpel wrote: [snip] You can clearly see both my CA and user certificates. Certutil has used my PKCS#11 module to obtain my user certificate. Then I launched the second commany you were suggesting: certutil -d . -L -n "HTC Touch HD T8282:Matej Kurpel" Now it popped up a message that certutil.exe has stopped working. From my PKCS11-spy logs it's apparent that it searched for the certificate, found it, got some of its atttributes, and then searched for a private key belonging to this certificate (and found it): FindObjectsInit - FindObjects - FindObjectsFinal. That's all it did and then crashed. Looks like something is wrong with my certificate but how can I check it when certutil is crashing? Maybe something is wrong with your PKCS#11 module, or maybe something is wrong with certutil. What does the stack backtrace from the crash show you? Hey, excuse my n00b-ness :) but I don't know how to get the stack trace. I wanted to create the certutil project in VC++ and compile and debug it there but I couldn't find a header file "prcpucfg.h" which, according to google, had yet to be generated by make (grrr...). So I went to compile NSS myself. I did everything according to this page: http://www.mozilla.org/projects/security/pki/nss/buildnss_32.html But after launching the final step, "gmake nss_build_all", all I get are some errors: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. cl : Command line warning D9002 : ignoring unknown option '-ne' cl : Command line warning D9024 : unrecognized source file type '2>&1', object f ile assumed cl : Command line warning D9024 : unrecognized source file type '|', object file assumed cl : Command line warning D9024 : unrecognized source file type 'sed', object fi le assumed cl : Command line warning D9024 : unrecognized source file type 's|.* \([0-9]\+\ .[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?\).*|\1|p', object file assumed gmake: *** No rule to make target `ns_build_all'. Stop. Google provides no solutions. I am starting to tear my hair out when it comes to these annoying trouble with compiling and all the C/C++ stuff, when nothing works as it should. Please help me :( M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: Thunderbird: "Could not verify this certificate for unknown reasons"
On 23. 10. 2010 22:18, Nelson B Bolyard wrote: On 2010-10-21 13:31 PDT, Matej Kurpel wrote: This looks like Thunderbird cannot find the user certificate in its database. Well, it shouldn't anyway, since it resides on the token provided by a PKCS#11 module I am developing. Right. It's not necessary for the cert to be in the database. It's only necessary that NSS can find it in one of the attached tokens. However, in its properties it says it couldn't verify the certificate for unknown reasons. And the CA certificate is added into the authorities correctly. Any more ideas, please? For purposes of your command line testing, you should add your PKCS#11 module to the secmod.db configuration file, using the modutil program. Thereafter, you should be able to get the command line utilities to see and attempt to verity the certificate in your token. I'd tell you how to do that, but you seem to be doing VERY VERY well at figuring it out on your own! Here are some hints: certutil -d . -L -h all certutil -d . -L -n "my token name:my cert name" I did what you said but didn't really get anywhere... First I did this: certutil -d . -L -h all It showed all certificates in this way: Mekova CA - CA organizacia CT,C,C Google Internet Authority,, DigiCert High Assurance CA-3 ,, VeriSign Class 3 Extended Validation SSL CA ,, HTC Touch HD T8282:Matej Kurpel u,u,u Builtin Object Token:Verisign/RSA Secure Server CA CG,C,p Builtin Object Token:GTE CyberTrust Root CA CG,C,C (more Builtin Object token lines following) You can clearly see both my CA and user certificates. Certutil has used my PKCS#11 module to obtain my user certificate. Then I launched the second commany you were suggesting: certutil -d . -L -n "HTC Touch HD T8282:Matej Kurpel" Now it popped up a message that certutil.exe has stopped working. From my PKCS11-spy logs it's apparent that it searched for the certificate, found it, got some of its atttributes, and then searched for a private key belonging to this certificate (and found it): FindObjectsInit - FindObjects - FindObjectsFinal. That's all it did and then crashed. Looks like something is wrong with my certificate but how can I check it when certutil is crashing? :( Windows didn't have any problems with the certificate... Also in an ASN.1 Editor I have downloaded off the web, the certificate loads up fine. Can you suggest anything more to try, please? pkcs11-spy log begin - 9: C_OpenSession [in] slotID = 0x0 [in] flags = 0x4 pApplication=0219E338 Notify=004564D0 [out] *phSession = 0x1 Returned: 0 CKR_OK 10: C_GetMechanismList [in] slotID = 0x0 [out] pMechanismList[1]: Count is 1 Returned: 0 CKR_OK 11: C_GetMechanismList [in] slotID = 0x0 [out] pMechanismList[1]: CKM_RSA_PKCS Returned: 0 CKR_OK 12: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[1]: CKA_CLASS CKO_NETSCAPE_BUILTIN_ROOT_LIST Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 13: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_TOKEN True CKA_CLASS CKO_CERTIFICATE Returned: 0 CKR_OK 14: C_FindObjects [in] hSession = 0x1 [in] ulMaxObjectCount = 0xa [out] ulObjectCount = 0x1 Object 1 Matches Returned: 0 CKR_OK 15: C_FindObjectsFinal [in] hSession = 0x1 Returned: 0 CKR_OK 16: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_TOKEN requested with 0 buffer CKA_LABEL requested with 0 buffer [out] pTemplate[2]: CKA_TOKEN has size 1 CKA_LABEL has size 12 Returned: 0 CKR_OK 17: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_TOKEN requested with 1 buffer CKA_LABEL requested with 12 buffer [out] pTemplate[2]: CKA_TOKEN True CKA_LABEL [size : 0xC (12)] 4D617465 6A204B75 7270656C M a t e j . K u r p e l Returned: 0 CKR_OK 18: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[10]: CKA_CLASS requested with 0 buffer CKA_TOKEN requested with 0 buffer CKA_LABEL requested with 0 buffer CKA_CERTIFICATE_TYPE requested with 0 buffer CKA_IDrequested with 0 buffer CKA_VALUE requested with 0 buffer CKA_ISSUERrequested with 0 buffer CKA_SERIAL_NUMBER requested with 0 buffer CKA_SUBJECT requested with 0 buffer CKA_NETSCAPE_EMAIL(Netsc) requested with 0 buffer [out] pTemplate[10]: CKA_CLASS has size 4 CKA_TOKEN has size 1 CKA_LABEL has size 12 CKA_
Re: Thunderbird: "Could not verify this certificate for unknown reasons"
On 20. 10. 2010 21:01, Nelson B Bolyard wrote: On 2010-10-20 09:54 PDT, Matej Kurpel wrote: Hello, I have set up my own CA and issued one certificate signed by this CA. However, I cannot use this certificate to send signed e-mail from Thunderbird. It says "Could not verify this certificate for unknown reasons". PSM's infamous "for an unknown reason" error message, the bane of my existence for about a decade now. See https://bugzilla.mozilla.org/show_bug.cgi?id=desired When any NSS function fails, NSS always provides a reason code. But years ago, the manager of the group responsible for implementing the GUI for Mozilla's crypto security decided that error details were unimportant, and so, to save schedule time, he allowed his employee to do a very incomplete job of producing error message strings for the various error codes, and simply present a default string in all other cases that says "for an unknown reason". We've been plagued with that ever since. In all the years since then, it has never been important to Mozilla UI folks to fix this. It seems to be an entrance requirement to get into GUI design school. They ask you "is security UI design important?", and if you say "yes", or even hesitate to say "NO!", you're out. ("HELL NO!" is the preferred answer.) So, here's what you do. Use one of NSS's command line tools to verify your certificate chain for the email certificate usage, and see what it says. Thank you, Nelson. I have downloaded the NSS utils and used the certutil. I have copied *.db files from Thunderbird's profile folder to the same folder in which certutil and other utils reside. And I have put both my CA certificate (ca_cert.der with subject address mekova...@spam.la) and the user certificate (cert.der with subject address mkur...@gmail.com), in the same folder. Then I made this to validate my user certificate: certutil -V -n mkur...@gmail.com -u -SR -e -l -d . It said: certutil: could not find certificate named "mkur...@gmail.com": security library : bad database. So, apparently the user certificate wasn't in the database. I then tried to verify the CA certificate: certutil -V -n mekova...@spam.la -u -SR -e -l -d . certutil: certificate is valid Then I added the user certificate into the database and tried to verify it again: certutil -A -n mkur...@gmail.com -t Pug -d . -i cert.der certutil -V -n mkur...@gmail.com -u -SR -e -l -d . certutil: certificate is valid This looks like Thunderbird cannot find the user certificate in its database. Well, it shouldn't anyway, since it resides on the token provided by a PKCS#11 module I am developing. However, in its properties it says it couldn't verify the certificate for unknown reasons. And the CA certificate is added into the authorities correctly. Any more ideas, please? M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Thunderbird: "Could not verify this certificate for unknown reasons"
Hello, I have set up my own CA and issued one certificate signed by this CA. However, I cannot use this certificate to send signed e-mail from Thunderbird. It says "Could not verify this certificate for unknown reasons". I don't understand; I have added the root CA certificate into the Authorities tab in Certificate Manager and it says the CA certificate is OK (and I have checked all three checkboxes of trust when adding it). Now, Windows itself doesn't have a problem with this; it was sufficient to just add the root CA certificate into the Trusted CA certificate store, and then it recognized and validated the second certificate without any trouble. Can someone point me in the right direction on what does Thunderbird not like? Thanks in advance. M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: PKCS#11: C_Sign provides invalid signature
On 16. 10. 2010 18:33, Nelson B Bolyard wrote: On 2010-10-16 06:25 PDT, Matej Kurpel wrote: Hello, I am developing a PKCS#11 module to be used with Thunderbird. However, I have trouble providing a valid signature for e-mails. The mechanism used is CKM_RSA_PKCS and I have a 1024bit private key along with the certificate, stored on the token. The signature is generated in a C# .NET CF program running on the device, using this piece of code: RSACryptoServiceProvider rsa = PKCS11Library.TryLoadPK(Encoding.ASCII.GetString(keyPath, 0, keyPath.Length), out keyRawData); // this returns a valid RSACryptoServiceProvider instance signature = rsa.SignData(data, new SHA1CryptoServiceProvider()); //signs the data we need I am not sure about the second parameter of the rsa.SignData method - the documentation says it is of type "object" and it's the mechanism to be used to sign the data. I cannot think of any more appropriate object to be passed there than SHA1CryptoServiceProvider. This isn't really the place to come for advice about C# crypto ... but ... the SignData method provides the wrong level of functionality for CKM_RSA_PKCS. The entire RSA signature creation process usually includes these steps: 1) Choose a hash algorithm (e.g. SHA-something or MD5), get the OID string (number) value that identifies that algorithm, and use that algorithm to hash all the data to be signed. 2) Construct an ASN.1 DER formatted buffer called a "DigestInfo" using that OID string and that hash value. 3) Construct a PKCS#1 formatted buffer (either v 1.5 or v2.0) from that DER formatted buffer. 4) Perform an RSA private key operation on that PKCS#1 formatted buffer. In some applications, steps 2 and/or 3 are modified, and custom buffer formats are used instead of the pure DigestInfo and/or PKCS#1 formats. The CKM_RSA_PKCS mechanism you're attempting to implement does only the last two of those steps. It treats the input it is given as a DigestInfo. It then does the PKCS#1 formatting according to PKCS#1 version 1.5. This gives its user the flexibility to implement the normal DigestInfo buffer format, or any other custom format. PKCS#1 Version 2.0 formatting is incompatible with CKM_RSA_PKCS. PKCS#1 Version 2.0 formatting is done by another PKCS#11 mechanism, namely CKM_RSA_PKCS_OAEP. The SignData method you're trying to use does all the above steps. It wants the input to step 1. Since you're implementing CKM_RSA_PKCS, the data you're given is the input to step 3, the output from step 2. You can deconstruct it and obtain from it the output from step 1, but you cannot go back to having the input to step 1, because the hash is irreversible. So, I think you cannot use SignData to implement CKM_RSA_PKCS. C#'s RSACryptoServiceProvider class also features a SignHash method that does the last three of those steps. It expects to receive, as input, the hash value and the OID string. It constructs the DigestInfo and the PKCS#1 buffer and does the RSA private key operation. Whether it formats the PKCS#1 buffer according PKCS#1 version 1.5 or version 2.0 is unknown to me. I couldn't find any reference to PKCS in MSDN's C# documentation. Thank you, Nelson, it works now. I used the SignHash method instead, with the OID string "1.3.14.3.2.26", which means SHA1. And I took just the last 20 bytes of the provided data to sign - which is the hash. M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
PKCS#11: C_Sign provides invalid signature
Hello, I am developing a PKCS#11 module to be used with Thunderbird. However, I have trouble providing a valid signature for e-mails. The mechanism used is CKM_RSA_PKCS and I have a 1024bit private key along with the certificate, stored on the token. The signature is generated in a C# .NET CF program running on the device, using this piece of code: RSACryptoServiceProvider rsa = PKCS11Library.TryLoadPK(Encoding.ASCII.GetString(keyPath, 0, keyPath.Length), out keyRawData); // this returns a valid RSACryptoServiceProvider instance signature = rsa.SignData(data, new SHA1CryptoServiceProvider()); //signs the data we need I am not sure about the second parameter of the rsa.SignData method - the documentation says it is of type "object" and it's the mechanism to be used to sign the data. I cannot think of any more appropriate object to be passed there than SHA1CryptoServiceProvider. Now, the problem is that the signed e-mail is sent correctly but after receiving it, Thunderbird states that the signature is invalid. My question is, is there any format NSS (Thunderbird) needs the signature in? Does the signature I am providing, look properly at a first glance? (Please look at line 45 in the pkcs11-spy log I am attaching). PKCS11 SPY LOG BEGIN 32: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_IDrequested with 0 buffer CKA_CLASS requested with 0 buffer [out] pTemplate[2]: CKA_IDhas size 4 CKA_CLASS has size 4 Returned: 0 CKR_OK 33: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_IDrequested with 4 buffer CKA_CLASS requested with 4 buffer [out] pTemplate[2]: CKA_ID[size : 0x4 (4)] 0100 CKA_CLASS CKO_CERTIFICATE Returned: 0 CKR_OK 34: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_ID[size : 0x4 (4)] 0100 CKA_CLASS CKO_PRIVATE_KEY Returned: 0 CKR_OK 35: C_FindObjects [in] hSession = 0x1 [in] ulMaxObjectCount = 0x1 [out] ulObjectCount = 0x1 Object 2 Matches Returned: 0 CKR_OK 36: C_FindObjectsFinal [in] hSession = 0x1 Returned: 0 CKR_OK 37: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x2 [in] pTemplate[1]: CKA_KEY_TYPE requested with 4 buffer [out] pTemplate[1]: CKA_KEY_TYPE CKK_RSA Returned: 0 CKR_OK 38: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x2 [in] pTemplate[1]: CKA_TOKEN requested with 1 buffer [out] pTemplate[1]: CKA_TOKEN True Returned: 0 CKR_OK 39: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x2 [in] pTemplate[1]: CKA_PRIVATE requested with 1 buffer [out] pTemplate[1]: CKA_PRIVATE True Returned: 0 CKR_OK 40: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x2 [in] pTemplate[1]: CKA_MODULUS requested with 0 buffer [out] pTemplate[1]: CKA_MODULUS has size 128 Returned: 0 CKR_OK 41: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x2 [in] pTemplate[1]: CKA_MODULUS requested with 128 buffer [out] pTemplate[1]: CKA_MODULUS [size : 0x80 (128)] D0B54A0E 53C59293 278EE27A 928C30CB 4A1942F6 DE32B8A4 951196DF 53FE8469 7225D5B0 98421497 C7C70428 2468A022 C17B0E51 E17B86C4 E0624BED 398FCDCD 422F789A 9518E4D4 DC07DA20 186BD121 2B80725E 8AE34A68 78FBC43E 6F3A2A95 DC808706 01C8A576 B5A072E1 2F773240 F60AF083 5021112A E9F0CB7F 98A7EEC5 Returned: 0 CKR_OK 42: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x2 [in] pTemplate[1]: CKA_PRIVATE requested with 1 buffer [out] pTemplate[1]: CKA_PRIVATE True Returned: 0 CKR_OK 43: C_OpenSession [in] slotID = 0x0 [in] flags = 0x4 pApplication=068DE800 Notify=5F8B5E19 [out] *phSession = 0x2 Returned: 0 CKR_OK 44: C_SignInit [in] hSession = 0x2 pMechanism->type=CKM_RSA_PKCS [in] hKey = 0x2 Returned: 0 CKR_OK 45: C_Sign [in] hSession = 0x2 [in] pData[ulDataLen] [size : 0x23 (35)] 30213009 06052B0E 03021A05 0004149A E91D78EE 1FDC8F4F A65E41A2 1263BF31 94C4D2 [out] pSignature[*pulSignatureLen] [size : 0x80 (128)] 63334030 9439D903 9645AC11 C1C05136 0B17A571 16E3F223 06CA4941 CB0721E5 194CF829 43DF0DE9 AB6BD5DF 051A8906 1D974171 6879468E 1F043C4B 7763E607 D0163299 54AA23B4 4BD221B7 B8F1F880 23D7E032 2AB6C7D9 18C29AEF 23603C08 E91BE397 303271E4 1850AC57 B53CD457 D10056DE 3C7CCB0F 99AFFF51 86CC3E28 Returned: 0 CKR_OK 46: C_CloseSession [in] hSession = 0x2 Returned: 0 CKR_OK 47: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_IDrequested with 0 buffer CKA_CLASS requested with 0 buffer [out] pTemplate[2]: CKA_IDhas size 4 CKA_CLASS
Re: NSS and PKCS#11 Certificate+Private key
On 10. 10. 2010 14:41, Matej Kurpel wrote: On 9. 10. 2010 14:44, Matej Kurpel wrote: Hello, I am developing a PKCS#11 module for my diploma thesis and I am having problems with Thunderbird not recognizing my certificate for signing. When I want to set it for signing using the Security tab of Account settings (by clicking Select...), Thunderbird says that "Certificate Manager can't locate a valid certificate that can be used to digitally sign your messages". However, I am able to view it properly, using the Certificate Manager. It states that the certificate has been verified for some number of purposes, including "Email signer Certificate". It is a self-signed certificate and has object handle 1 in my device, and its CKA_ID is "ID_Mek". The private key for this certificate has the same CKA_ID and the object handle is 2. In my opensc-spy log I can see that it should work this way: - Thunderbird searches for token certificates - Gets attributes of the certificates (including CKA_ID) - Searches for private keys with the same CKA_ID - ...Continues with whatever it needs to do. I can see the first three steps repeating twice, and then Thunderbird gives up. I really don't understand why doesn't it proceed; I am giving it object handle 2 as my private key, so where is the problem?... I am attaching my opensc-spy log with unneccessary info stripped out. Thanks in advance for any clues. Matej Kurpel --- SPY LOG BEGIN 9: C_OpenSession [in] slotID = 0x0 [in] flags = 0x4 pApplication=067E3000 Notify=6A2D5E19 [out] *phSession = 0x1 Returned: 0 CKR_OK 10: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[1]: CKA_CLASS CKO_NETSCAPE_BUILTIN_ROOT_LIST Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 11: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_TOKEN True CKA_CLASS CKO_CERTIFICATE Returned: 0 CKR_OK 12: C_FindObjects [in] hSession = 0x1 [in] ulMaxObjectCount = 0xa [out] ulObjectCount = 0x1 Object 1 Matches Returned: 0 CKR_OK 13: C_FindObjectsFinal [in] hSession = 0x1 Returned: 0 CKR_OK 14: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_TOKEN requested with 0 buffer CKA_LABEL requested with 0 buffer [out] pTemplate[2]: CKA_TOKEN has size 4 CKA_LABEL has size 8 Returned: 0 CKR_OK 15: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_TOKEN requested with 4 buffer CKA_LABEL requested with 8 buffer [out] pTemplate[2]: CKA_TOKEN True CKA_LABEL [size : 0x8 (8)] 43657274 204D656B C e r t . M e k Returned: 0 CKR_OK 16: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[10]: CKA_CLASS requested with 0 buffer CKA_TOKEN requested with 0 buffer CKA_LABEL requested with 0 buffer CKA_CERTIFICATE_TYPE requested with 0 buffer CKA_IDrequested with 0 buffer CKA_VALUE requested with 0 buffer CKA_ISSUERrequested with 0 buffer CKA_SERIAL_NUMBER requested with 0 buffer CKA_SUBJECT requested with 0 buffer CKA_NETSCAPE_EMAIL(Netsc) requested with 0 buffer [out] pTemplate[10]: CKA_CLASS has size 4 CKA_TOKEN has size 4 CKA_LABEL has size 8 CKA_CERTIFICATE_TYPE has size 4 CKA_IDhas size 6 CKA_VALUE has size 676 CKA_ISSUERhas size 107 CKA_SERIAL_NUMBER has size 11 CKA_SUBJECT has size 107 CKA_NETSCAPE_EMAIL(Netsc) has size -1 Returned: 18 CKR_ATTRIBUTE_TYPE_INVALID 17: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[10]: CKA_CLASS requested with 4 buffer CKA_TOKEN requested with 4 buffer CKA_LABEL requested with 8 buffer CKA_CERTIFICATE_TYPE requested with 4 buffer CKA_IDrequested with 6 buffer CKA_VALUE requested with 676 buffer CKA_ISSUERrequested with 107 buffer CKA_SERIAL_NUMBER requested with 11 buffer CKA_SUBJECT requested with 107 buffer CKA_NETSCAPE_EMAIL(Netsc) requested with 0 buffer [out] pTemplate[10]: CKA_CLASS CKO_CERTIFICATE CKA_TOKEN True CKA_LABEL [size : 0x8 (8)] 43657274 204D656B C e r t . M e k CKA_CERTIFICATE_TYPE CKC_X_509 CKA_ID[size : 0x6 (6)] 49445F4D 656B CKA_VALUE [size : 0x2A4 (676)] 308202A0 30820209 A0030201 02020900 92159945 D0C657FE 300D0609 2A864886 F70D0101 05050030 69310B30 09060355 04061302 534B
Re: NSS and PKCS#11 Certificate+Private key
On 9. 10. 2010 14:44, Matej Kurpel wrote: Hello, I am developing a PKCS#11 module for my diploma thesis and I am having problems with Thunderbird not recognizing my certificate for signing. When I want to set it for signing using the Security tab of Account settings (by clicking Select...), Thunderbird says that "Certificate Manager can't locate a valid certificate that can be used to digitally sign your messages". However, I am able to view it properly, using the Certificate Manager. It states that the certificate has been verified for some number of purposes, including "Email signer Certificate". It is a self-signed certificate and has object handle 1 in my device, and its CKA_ID is "ID_Mek". The private key for this certificate has the same CKA_ID and the object handle is 2. In my opensc-spy log I can see that it should work this way: - Thunderbird searches for token certificates - Gets attributes of the certificates (including CKA_ID) - Searches for private keys with the same CKA_ID - ...Continues with whatever it needs to do. I can see the first three steps repeating twice, and then Thunderbird gives up. I really don't understand why doesn't it proceed; I am giving it object handle 2 as my private key, so where is the problem?... I am attaching my opensc-spy log with unneccessary info stripped out. Thanks in advance for any clues. Matej Kurpel --- SPY LOG BEGIN 9: C_OpenSession [in] slotID = 0x0 [in] flags = 0x4 pApplication=067E3000 Notify=6A2D5E19 [out] *phSession = 0x1 Returned: 0 CKR_OK 10: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[1]: CKA_CLASS CKO_NETSCAPE_BUILTIN_ROOT_LIST Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 11: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_TOKEN True CKA_CLASS CKO_CERTIFICATE Returned: 0 CKR_OK 12: C_FindObjects [in] hSession = 0x1 [in] ulMaxObjectCount = 0xa [out] ulObjectCount = 0x1 Object 1 Matches Returned: 0 CKR_OK 13: C_FindObjectsFinal [in] hSession = 0x1 Returned: 0 CKR_OK 14: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_TOKEN requested with 0 buffer CKA_LABEL requested with 0 buffer [out] pTemplate[2]: CKA_TOKEN has size 4 CKA_LABEL has size 8 Returned: 0 CKR_OK 15: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_TOKEN requested with 4 buffer CKA_LABEL requested with 8 buffer [out] pTemplate[2]: CKA_TOKEN True CKA_LABEL [size : 0x8 (8)] 43657274 204D656B C e r t . M e k Returned: 0 CKR_OK 16: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[10]: CKA_CLASS requested with 0 buffer CKA_TOKEN requested with 0 buffer CKA_LABEL requested with 0 buffer CKA_CERTIFICATE_TYPE requested with 0 buffer CKA_IDrequested with 0 buffer CKA_VALUE requested with 0 buffer CKA_ISSUERrequested with 0 buffer CKA_SERIAL_NUMBER requested with 0 buffer CKA_SUBJECT requested with 0 buffer CKA_NETSCAPE_EMAIL(Netsc) requested with 0 buffer [out] pTemplate[10]: CKA_CLASS has size 4 CKA_TOKEN has size 4 CKA_LABEL has size 8 CKA_CERTIFICATE_TYPE has size 4 CKA_IDhas size 6 CKA_VALUE has size 676 CKA_ISSUERhas size 107 CKA_SERIAL_NUMBER has size 11 CKA_SUBJECT has size 107 CKA_NETSCAPE_EMAIL(Netsc) has size -1 Returned: 18 CKR_ATTRIBUTE_TYPE_INVALID 17: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[10]: CKA_CLASS requested with 4 buffer CKA_TOKEN requested with 4 buffer CKA_LABEL requested with 8 buffer CKA_CERTIFICATE_TYPE requested with 4 buffer CKA_IDrequested with 6 buffer CKA_VALUE requested with 676 buffer CKA_ISSUERrequested with 107 buffer CKA_SERIAL_NUMBER requested with 11 buffer CKA_SUBJECT requested with 107 buffer CKA_NETSCAPE_EMAIL(Netsc) requested with 0 buffer [out] pTemplate[10]: CKA_CLASS CKO_CERTIFICATE CKA_TOKEN True CKA_LABEL [size : 0x8 (8)] 43657274 204D656B C e r t . M e k CKA_CERTIFICATE_TYPE CKC_X_509 CKA_ID[size : 0x6 (6)] 49445F4D 656B CKA_VALUE [size : 0x2A4 (676)] 308202A0 30820209 A0030201 02020900 92159945 D0C657FE 300D0609 2A864886 F70D0101 05050030 69310B30 09060355 04061302 534B3111 300F0603 5504080C 08536C6F 76616B69
NSS and PKCS#11 Certificate+Private key
Hello, I am developing a PKCS#11 module for my diploma thesis and I am having problems with Thunderbird not recognizing my certificate for signing. When I want to set it for signing using the Security tab of Account settings (by clicking Select...), Thunderbird says that "Certificate Manager can't locate a valid certificate that can be used to digitally sign your messages". However, I am able to view it properly, using the Certificate Manager. It states that the certificate has been verified for some number of purposes, including "Email signer Certificate". It is a self-signed certificate and has object handle 1 in my device, and its CKA_ID is "ID_Mek". The private key for this certificate has the same CKA_ID and the object handle is 2. In my opensc-spy log I can see that it should work this way: - Thunderbird searches for token certificates - Gets attributes of the certificates (including CKA_ID) - Searches for private keys with the same CKA_ID - ...Continues with whatever it needs to do. I can see the first three steps repeating twice, and then Thunderbird gives up. I really don't understand why doesn't it proceed; I am giving it object handle 2 as my private key, so where is the problem?... I am attaching my opensc-spy log with unneccessary info stripped out. Thanks in advance for any clues. Matej Kurpel --- SPY LOG BEGIN 9: C_OpenSession [in] slotID = 0x0 [in] flags = 0x4 pApplication=067E3000 Notify=6A2D5E19 [out] *phSession = 0x1 Returned: 0 CKR_OK 10: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[1]: CKA_CLASS CKO_NETSCAPE_BUILTIN_ROOT_LIST Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 11: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_TOKEN True CKA_CLASS CKO_CERTIFICATE Returned: 0 CKR_OK 12: C_FindObjects [in] hSession = 0x1 [in] ulMaxObjectCount = 0xa [out] ulObjectCount = 0x1 Object 1 Matches Returned: 0 CKR_OK 13: C_FindObjectsFinal [in] hSession = 0x1 Returned: 0 CKR_OK 14: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_TOKEN requested with 0 buffer CKA_LABEL requested with 0 buffer [out] pTemplate[2]: CKA_TOKEN has size 4 CKA_LABEL has size 8 Returned: 0 CKR_OK 15: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_TOKEN requested with 4 buffer CKA_LABEL requested with 8 buffer [out] pTemplate[2]: CKA_TOKEN True CKA_LABEL [size : 0x8 (8)] 43657274 204D656B C e r t . M e k Returned: 0 CKR_OK 16: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[10]: CKA_CLASS requested with 0 buffer CKA_TOKEN requested with 0 buffer CKA_LABEL requested with 0 buffer CKA_CERTIFICATE_TYPE requested with 0 buffer CKA_IDrequested with 0 buffer CKA_VALUE requested with 0 buffer CKA_ISSUERrequested with 0 buffer CKA_SERIAL_NUMBER requested with 0 buffer CKA_SUBJECT requested with 0 buffer CKA_NETSCAPE_EMAIL(Netsc) requested with 0 buffer [out] pTemplate[10]: CKA_CLASS has size 4 CKA_TOKEN has size 4 CKA_LABEL has size 8 CKA_CERTIFICATE_TYPE has size 4 CKA_IDhas size 6 CKA_VALUE has size 676 CKA_ISSUERhas size 107 CKA_SERIAL_NUMBER has size 11 CKA_SUBJECT has size 107 CKA_NETSCAPE_EMAIL(Netsc) has size -1 Returned: 18 CKR_ATTRIBUTE_TYPE_INVALID 17: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[10]: CKA_CLASS requested with 4 buffer CKA_TOKEN requested with 4 buffer CKA_LABEL requested with 8 buffer CKA_CERTIFICATE_TYPE requested with 4 buffer CKA_IDrequested with 6 buffer CKA_VALUE requested with 676 buffer CKA_ISSUERrequested with 107 buffer CKA_SERIAL_NUMBER requested with 11 buffer CKA_SUBJECT requested with 107 buffer CKA_NETSCAPE_EMAIL(Netsc) requested with 0 buffer [out] pTemplate[10]: CKA_CLASS CKO_CERTIFICATE CKA_TOKEN True CKA_LABEL [size : 0x8 (8)] 43657274 204D656B C e r t . M e k CKA_CERTIFICATE_TYPE CKC_X_509 CKA_ID[size : 0x6 (6)] 49445F4D 656B CKA_VALUE [size : 0x2A4 (676)] 308202A0 30820209 A0030201 02020900 92159945 D0C657FE 300D0609 2A864886 F70D0101 05050030 69310B30 09060355 04061302 534B3111 300F0603 5504080C 08536C6F 76616B69 61311030 0E060355 04070C07 5472656E 63696E31 15301306
Re: 64bit NSS build on windows 7 x64
On 16. 9. 2010 15:28, David Stutzman wrote: configure: error: installation or configuration problem: C compiler cannot creat e executables. Just guessing here... could this be a problem with UAC? (User Account Control) M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
NSS and CKA_ALWAYS_AUTHENTICATE
Hello, I need to force authentication on the device everytime a sign operation is requested from my PKCS#11 library. From the specification, I understood that there is a flag CKA_ALWAYS_AUTHENTICATE of the private key which should be set to TRUE. However, NSS does not request the value of this attribute anywhere so I have no way of telling it that in order to use the key, C_Login needs to be called with user type CKU_CONTEXT_SPECIFIC. I did some google research and found out that currently NSS does not support any of these features (but the posts were quite older). My question is; is the described behavior still unsupported? If yes, are there any possibilities to achieve at least similar effect? Thanks, M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: PKCS#11 module: C_GetAttributeValue problems
Dňa 13. 8. 2010 18:35, Robert Relyea wrote / napísal(a): On 08/13/2010 05:37 AM, Konstantin Andreev wrote: On 08/13/10 04:44, Robert Relyea wrote: On Wed, Aug 11, 2010 at 1:18 PM, Matej Kurpel wrote: [ ... skip ... ] Later, thunderbird asks for its attributes CKA_TOKEN and CKA_LABEL but gives zero-sized buffers for both values. ... According to the specification (if I understood correctly), I should return CKR_BUFFER_TOO_SMALL and fill the ulValueLen properties to the length of the two attribute values, which makes perfect sense. No, you need to return CKR_OK. You only return CKR_BUFFER_TOO_SMALL if a buffer was supplied and it didn't fit (in which case you set the offending attribute length to -1). See the PKCS #11 spec for C_GetAttributeValue. By returning CKR_BUFFER_TOO_SMALL to NSS, you are telling it that the requested operation failed (That operation was to get the lengths of the attributes it wanted to read). Hello, Robert. Matej told us that buffers were supplied, but zero-size. He didn't tell that buffers were NULL. Ah, that case CKR_BUFFER_TOO_SMALL would be appriopriate. I'm pretty sure that that was not the case. I suspect he didn't check for NULL since I know of no where in NSS that would do such a thing, but I know exactly where we are asking for CKA_TOKEN and CKA_LABEL with a NULL buffer. see http://mxr.mozilla.org/security/source/security/nss/lib/pk11wrap/pk11obj.c#210 I am not sure, whether this applies to Matej issue, but PK11_GetAttributes is defective. It doesn't care about nullifying CK_ATTRIBUTE::pValue before 1st call to C_GetAttributeValue. The caller of PK11_GetAttributes should care about. Yes, it does require the caller to set things to NULL first.. bob -- Konstantin. Guys, I figured out that Thunderbird didn't like this assignment of CKA_TOKEN when assigning the values (with the buffers of right sizes already allocated): pTemplate[i].pValue = (CK_BBOOL *)TRUE; (but it compiled fine). I changed it to *((CK_BBOOL *)pTemplate[i].pValue) = TRUE; and it works perfectly! I am pretty n00b at C++ (well, still learning). I will avoid this mistake in the future. Thanks again for your willing to help :) M. Kurpel -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: PKCS#11 module: C_GetAttributeValue problems
Dňa 12. 8. 2010 11:03, Konstantin Andreev wrote / napísal(a): On 08/12/10 00:18, Matej Kurpel wrote: [ ... skip ...] Later, thunderbird asks for its attributes CKA_TOKEN and CKA_LABEL but gives zero-sized buffers for both values. This is where my problem lies - I don't know what to return and if I have to fill the values in the template or not. According to the specification (if I understood correctly), I should return CKR_BUFFER_TOO_SMALL and fill the ulValueLen properties to the length of the two attribute values, which makes perfect sense. Could you, please, provide stack trace at this point ? Which versions of NSS and Thunderbird you are using ? How do I get stack trace, please? I am using the latest stable release of Thunderbird (3.1.2) which I am normally using. Then thunderbird should ask for the values again (by calling C_GetAttributeValue again), but with the right buffer sizes. The problem is that it does not. -- Konstantin -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
PKCS#11 module: C_GetAttributeValue problems
Hello, I am trying to implement a PKCS#11 module for my diploma thesis. It is intended to be used with thunderbird. I am using opensc pkcs11-spy module to debug it. I have a problem for quite some days I don't seem to be able to solve myself. At first, thunderbird searches for token certificates (CKA_CLASS=CKO_CERTIFICATE and CKA_TOKEN=TRUE). I am returning an object with handle 0x1 (letting thunderbird know I have such a certificate). Later, thunderbird asks for its attributes CKA_TOKEN and CKA_LABEL but gives zero-sized buffers for both values. This is where my problem lies - I don't know what to return and if I have to fill the values in the template or not. According to the specification (if I understood correctly), I should return CKR_BUFFER_TOO_SMALL and fill the ulValueLen properties to the length of the two attribute values, which makes perfect sense. Then thunderbird should ask for the values again (by calling C_GetAttributeValue again), but with the right buffer sizes. The problem is that it does not. It only tries to find token objects with CKA_CLASS CKO_NETSCAPE_TRUST and then some CKO_NETSCAPE_CRLs, that is all. I found some examples on the internet, where instead of CKR_BUFFER_TOO_SMALL they return CKR_OK and everything works. For me it does not - as soon as I return CKR_OK, thunderbird crashes after leaving C_GetAttributeValue with the zero-sized buffers. So what should I do? I am really at loss now. I am attaching the appropriate part of the logs. Thanks for all responses. (PKCS11-SPY LOG BEGIN; uninteresting items omitted) 11: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_TOKEN True CKA_CLASS CKO_CERTIFICATE Returned: 0 CKR_OK 12: C_FindObjects [in] hSession = 0x1 [in] ulMaxObjectCount = 0xa [out] ulObjectCount = 0x1 Object 1 Matches Returned: 0 CKR_OK 13: C_FindObjectsFinal [in] hSession = 0x1 Returned: 0 CKR_OK 14: C_GetAttributeValue [in] hSession = 0x1 [in] hObject = 0x1 [in] pTemplate[2]: CKA_TOKEN requested with 0 buffer CKA_LABEL requested with 0 buffer [out] pTemplate[2]: CKA_TOKEN has size 1 CKA_LABEL has size 41 Returned: 336 CKR_BUFFER_TOO_SMALL 15: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_TOKEN True CKA_CLASS CKO_NETSCAPE_TRUST Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 16: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_CLASS CKO_NETSCAPE_CRL CKA_SUBJECT [size : 0x48 (72)] 3046310B 30090603 55040613 02555331 13301106 0355040A 130A476F 6F676C65 20496E63 31223020 06035504 03131947 6F6F676C 6520496E 7465726E 65742041 7574686F 72697479 Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 17: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_CLASS CKO_NETSCAPE_CRL CKA_SUBJECT [size : 0x50 (80)] 304E310B 30090603 55040613 02555331 10300E06 0355040A 13074571 75696661 78312D30 2B060355 040B1324 45717569 66617820 53656375 72652043 65727469 66696361 74652041 7574686F 72697479 Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 18: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_CLASS CKO_NETSCAPE_CRL CKA_SUBJECT [size : 0xBD (189)] 3081BA31 0B300906 03550406 13025553 31173015 06035504 0A130E56 65726953 69676E2C 20496E63 2E311F30 1D060355 040B1316 56657269 5369676E 20547275 7374204E 6574776F 726B313B 30390603 55040B13 32546572 6D73206F 66207573 65206174 20687474 70733A2F 2F77 2E766572 69736967 6E2E636F 6D2F7270 61202863 29303631 34303206 03550403 132B5665 72695369 676E2043 6C617373 20332045 7874656E 64656420 56616C69 64617469 6F6E2053 534C2043 41 Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 19: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_CLASS CKO_NETSCAPE_CRL CKA_SUBJECT [size : 0xCD (205)] 3081CA31 0B300906 03550406 13025553 31173015 06035504 0A130E56 65726953 69676E2C 20496E63 2E311F30 1D060355 040B1316 56657269 5369676E 20547275 7374204E 6574776F 726B313A 30380603 55040B13 31286329 20323030 36205665 72695369 676E2C20 496E632E 202D2046 6F722061 7574686F 72697A65 64207573 65206F6E 6C793145 30430603 55040313 3C566572 69536967 6E20436C 61737320 33205075 626C6963 20507269 6D617279 20436572 74696669 63617469 6F6E2041 7574686F 72697479 202D2047 35 Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 20: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_CLASS CKO_NETSCAPE_CRL CKA_SUBJECT [size : 0x50 (80)] 304E310B 30090603 55040613 02555331 10300E06 0355040A 13074571 75696661 78312D30 2B060355 040B1324 45717569 66617820 53656375 72652043 65727469 66696361 74652041 7574686F 72697479 Returned: 19 CKR_ATTRIBUTE_VALUE_INVALID 21: C_FindObjectsInit [in] hSession = 0x1 [in] pTemplate[2]: CKA_CLASS CKO_NETS