Closed palu3492 closed 4 years ago
What operating system do you use?
Ubuntu 16.04 virtual machine on Mac.
The serial number reported by SCARD_ATTR_VENDOR_IFD_SERIAL_NO
comes from the USB descriptor.
You should be able to see it using lsusb -v | grep iSerial
.
What do you get in that case?
I did not know if was also possible to get the device serial number using an APDU.
$ lsusb -vd 076b:5427 | grep iSerial
iSerial 3 010100534310112202019E563430630
It indeed shows the device's serial number as having a zero at the end.
So that is strange. I will have a look.
Can you generate a pcscd log as documented at https://pcsclite.apdu.fr/#support ?
Can you also use print(reader)
in your code and copy the result?
The serial number should be in the PC/SC reader name. https://ludovicrousseau.blogspot.com/2010/05/what-is-in-pcsc-reader-name.html
Sure thing. The output from printing the reader:
HID OMNIKEY 5427 CK (010100534E5634303101122020194630) 00 00
Again, the output from connection.getAttrib(SCARD_ATTR_VENDOR_IFD_SERIAL_NO) as decimal and ascii:
[48, 49, 48, 49, 48, 48, 53, 51, 52, 69, 53, 54, 51, 52, 51, 48, 51, 49, 48, 49, 49, 50, 50, 48, 50, 48, 49, 57, 52, 54, 51]
010100534E563430310112202019463
The pcscd log is attached. log.txt
Unfortunately the log file does not contain anything useful for the debug :-( I can't reproduce the problem on my side. Also I have a different behavior:
Broadcom Corp 5880 [Contacted SmartCard] (0123456789ABCD) 00 00
[48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 0]
0123456789ABCD
The serial number is NOT truncated. And I also get the final NUL byte in the Attribute buffer.
I fixed a problem with SCARD_ATTR_VENDOR_IFD_SERIAL_NO in the CCID driver version 1.4.24. https://ludovicrousseau.blogspot.com/2016/05/new-version-of-libccid-1424.html Ubuntu 16.04 provides libccid version 1.4.22-1. Please upgrade this driver and try again.
Interesting... I already have 1.4.22-1. That doesn't seem to be the problem. I tweaked your C code from https://ludovicrousseau.blogspot.com/2010/04/pcsc-sample-in-c.html and I was able to use SCardGetAttrib to return the correct serial number. Not sure if that means anything... Here's that truncated code:
LPBYTE pbAttr = NULL;
DWORD cByte = SCARD_AUTOALLOCATE;
DWORD w;
LONG lReturn;
lReturn = SCardGetAttrib(hCard,
65795,
(LPBYTE)&pbAttr,
&cByte);
for (w = 0; w < cByte; w++)
printf("%c", *(pbAttr+w));
Copied from the example at https://docs.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardgetattrib
1.4.22-1 is the problem. Upgrade to 1.4.24 or later.
Ah, yes, I read your message incorrectly 🤦♂️ That fixed it. Thank you very much.
I'm using an OMNIKEY 5427 CK reader and I'm having problems getting the serial number of the reader when using getAttrib on the reader connection. It seems to be short a byte. When I use the "OMNIKEY Specific Commands" and send an APDU command to the "Reader Information API" for the reader serial number, I get the correct serial number. Here are my code and output.
Out:
The OMNIKEY web interface to my reader also shows the serial number with a trailing zero.