SlotId Problem with two smartcard reader

243 views
Skip to first unread message

cape...@gmail.com

unread,
Oct 21, 2013, 6:45:42 AM10/21/13
to pkcs11...@googlegroups.com
Hi, i've the following problem. I've attached two smartcard reader. When i call WaitForSlotEvent(false, out bolOccurred, out slotId);
in slotId, when i insert a smartcard, whether slot i choose, i obtain always the same Id. Did you have noticed such a problem?
I'm working on Windows 8 64 bit (my project is compiled as x86).
Thank you,
Carlo

Jaroslav Imrich

unread,
Oct 21, 2013, 3:23:16 PM10/21/13
to pkcs11...@googlegroups.com, cape...@gmail.com
Hello Carlo,

you are using WaitForSlotEvent() in blocking mode (first argument "dontBlock" is set to false) and I can confirm I've seen PKCS#11 libraries that behave strangely in this mode: some libraries did detect event many seconds after it occurred, others did report more than one event for just one physical card insertion/removal etc. This is not Pkcs11Interop issue. It is problem of unmanaged PKCS#11 library.

I have created a simple console application that demonstrates WaitForSlotEvent() in non-blocking mode:

using System;
using Net.Pkcs11Interop.HighLevelAPI;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (Pkcs11 pkcs11 = new Pkcs11("siecap11.dll", true))
            {
                while (true)
                {
                    bool eventOccured = false;
                    ulong slotId = 0;
                    pkcs11.WaitForSlotEvent(true, out eventOccured, out slotId);
                    if (eventOccured)
                        Console.WriteLine("{0:u} - Event occured in slot {1}", DateTime.UtcNow, slotId);
                }
            }
        }
    }
}

I have also tested this application on my system with two readers and it produced following output:

2013-10-21 18:57:21Z - Event occured in slot 1
2013-10-21 18:57:24Z - Event occured in slot 2
2013-10-21 18:57:26Z - Event occured in slot 2
2013-10-21 18:57:28Z - Event occured in slot 1
2013-10-21 18:57:30Z - Event occured in slot 1
2013-10-21 18:57:32Z - Event occured in slot 2
2013-10-21 18:57:34Z - Event occured in slot 1
2013-10-21 18:57:35Z - Event occured in slot 2

Could you please test non-blocking mode and let me know if it works as expected?

-- 
Kind Regards

Jaroslav Imrich
www.pkcs11interop.net


--
You received this message because you are subscribed to the Google Groups "Pkcs11Interop" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pkcs11intero...@googlegroups.com.
To post to this group, send email to pkcs11...@googlegroups.com.
Visit this group at http://groups.google.com/group/pkcs11interop.

cape...@gmail.com

unread,
Oct 24, 2013, 11:02:17 AM10/24/13
to pkcs11...@googlegroups.com, cape...@gmail.com
Ok, i've just tried with a different kind of reader, using "block" and "nonblock", but without success. I've finally performed same tests but with different smartcard (using a different pkcs library) and everything works correctly. The problem is that the library incryptoki2.dll (used by Italy's "camera di commercio") communicates always the same slot id. So, as you said, the problem should be not in the pkcs11interop library but with this particular pkcs library implementation.
Thank you very much,
Carlo.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages