Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET_DEVICE_STATUS command reports wrong smart card serial number #76

Open
robinkrahl opened this issue Dec 27, 2018 · 3 comments
Open

Comments

@robinkrahl
Copy link

The serial numbers reported by gpg --card-status and by the GET_STATUS command diverge for my Nitrokey Storage:

$ gpg --card-status
[…]
Serial number ....: 0000636F
[…]
$ ./sn-test
[…]
[Thu Dec 27 12:45:03 2018][DEBUG_L1]	=> GET_DEVICE_STATUS
..
[Thu Dec 27 12:45:04 2018][DEBUG_L1]	<= GET_DEVICE_STATUS 0 1
[Thu Dec 27 12:45:04 2018][DEBUG]	Incoming HID packet:
[Thu Dec 27 12:45:04 2018][DEBUG]	Device status:	0 OK
[…]
 ActiveSmartCardID_u32:	327680
[…]

Serial number: 00050000

sn-test.c:

#include <stdio.h>
#include <libnitrokey/NK_C_API.h>

int main(void)
{
	NK_set_debug(true);
	int err = NK_login_auto();
	if (err == 0) {
		fprintf(stderr, "Could not connect to Nitrokey.\n");
		return 1;
	}
	char *sn = NK_device_serial_number();
	printf("Serial number: %s\n", sn);
	return 0;
}

This seems to be a bug – or am I missing something?

@szszszsz
Copy link
Member

Hi!
It looks like a bug indeed. libnitrokey runs proper status calls for each device (NitrokeyManager.cc#L361-L376), so it might be this is a Storage's firmware side issue.

@robinkrahl
Copy link
Author

I just noticed that this is the GET_DEVICE_STATUS command, not GET_STATUS.

@robinkrahl robinkrahl changed the title GET_STATUS command reports wrong smart card serial number GET_DEVICE_STATUS command reports wrong smart card serial number Jan 5, 2020
@robinkrahl
Copy link
Author

As far as I see, the problem must be in one of the following functions:

  1. GetSmartCardStatus in USER_INTERFACE/html_io.c
  2. LA_OpenPGP_V20_GetAID in CCID/LOCAL_ACCESS/OpenPGP_V20.c

But as I am not familiar with the OpenPGP card interface, I can’t track it down any further.

robinkrahl added a commit to robinkrahl/nitrocli that referenced this issue Jan 14, 2020
This patch implements the list command that lists all attached Nitrokey
devices.  Currently the Nitrokey Storage does not report its serial
number during HID enumeration, see [0].  So if we detect a Nitrokey
Storage device, we connect to it and use the get_serial_number function
to query its serial number.  This can be disabled using the --no-connect
option.

Note that even the get_serial_number function reports a wrong serial
number for the Nitrokey Storage, see [1].

[0] Nitrokey/nitrokey-storage-firmware#88
[1] Nitrokey/nitrokey-storage-firmware#76
robinkrahl added a commit to robinkrahl/nitrocli that referenced this issue Jan 15, 2020
This patch implements the list command that lists all attached Nitrokey
devices.  Currently the Nitrokey Storage does not report its serial
number during HID enumeration, see [0].  So if we detect a Nitrokey
Storage device, we connect to it and use the get_serial_number function
to query its serial number.  This can be disabled using the --no-connect
option.

Note that even the get_serial_number function reports a wrong serial
number for the Nitrokey Storage, see [1].

[0] Nitrokey/nitrokey-storage-firmware#88
[1] Nitrokey/nitrokey-storage-firmware#76
robinkrahl added a commit to robinkrahl/nitrocli that referenced this issue Jan 15, 2020
This patch implements the list command that lists all attached Nitrokey
devices.  Currently the Nitrokey Storage does not report its serial
number during HID enumeration, see [0].  So if we detect a Nitrokey
Storage device, we connect to it and use the get_serial_number function
to query its serial number.  This can be disabled using the --no-connect
option.

Note that even the get_serial_number function reports a wrong serial
number for the Nitrokey Storage, see [1].

[0] Nitrokey/nitrokey-storage-firmware#88
[1] Nitrokey/nitrokey-storage-firmware#76
d-e-s-o pushed a commit to d-e-s-o/nitrocli that referenced this issue Jan 15, 2020
This patch implements the list command that lists all attached Nitrokey
devices.  Currently the Nitrokey Storage does not report its serial
number during HID enumeration, see [0].  So if we detect a Nitrokey
Storage device, we connect to it and use the get_serial_number function
to query its serial number.  This can be disabled using the --no-connect
option.

Note that even the get_serial_number function reports a wrong serial
number for the Nitrokey Storage, see [1].

[0] Nitrokey/nitrokey-storage-firmware#88
[1] Nitrokey/nitrokey-storage-firmware#76
d-e-s-o pushed a commit to d-e-s-o/nitrocli that referenced this issue Jan 15, 2020
This patch implements the list command that lists all attached Nitrokey
devices.  Currently the Nitrokey Storage does not report its serial
number during HID enumeration, see [0].  So if we detect a Nitrokey
Storage device, we connect to it and use the get_serial_number function
to query its serial number.  This can be disabled using the --no-connect
option.

Note that even the get_serial_number function reports a wrong serial
number for the Nitrokey Storage, see [1].

[0] Nitrokey/nitrokey-storage-firmware#88
[1] Nitrokey/nitrokey-storage-firmware#76
d-e-s-o pushed a commit to d-e-s-o/nitrocli that referenced this issue Apr 4, 2020
This patch implements the list command that lists all attached Nitrokey
devices.  Currently the Nitrokey Storage does not report its serial
number during HID enumeration, see [0].  So if we detect a Nitrokey
Storage device, we connect to it and use the get_serial_number function
to query its serial number.  This can be disabled using the --no-connect
option.

Note that even the get_serial_number function reports a wrong serial
number for the Nitrokey Storage, see [1].

[0] Nitrokey/nitrokey-storage-firmware#88
[1] Nitrokey/nitrokey-storage-firmware#76
d-e-s-o pushed a commit to d-e-s-o/nitrocli that referenced this issue Apr 4, 2020
This patch implements the list command that lists all attached Nitrokey
devices.  Currently the Nitrokey Storage does not report its serial
number during HID enumeration, see [0].  So if we detect a Nitrokey
Storage device, we connect to it and use the get_serial_number function
to query its serial number.  This can be disabled using the --no-connect
option.

Note that even the get_serial_number function reports a wrong serial
number for the Nitrokey Storage, see [1].

[0] Nitrokey/nitrokey-storage-firmware#88
[1] Nitrokey/nitrokey-storage-firmware#76
d-e-s-o pushed a commit to d-e-s-o/nitrocli that referenced this issue Apr 4, 2020
This patch implements the list command that lists all attached Nitrokey
devices.  Currently the Nitrokey Storage does not report its serial
number during HID enumeration, see [0].  So if we detect a Nitrokey
Storage device, we connect to it and use the get_serial_number function
to query its serial number.  This can be disabled using the --no-connect
option.

Note that even the get_serial_number function reports a wrong serial
number for the Nitrokey Storage, see [1].

[0] Nitrokey/nitrokey-storage-firmware#88
[1] Nitrokey/nitrokey-storage-firmware#76
d-e-s-o pushed a commit to d-e-s-o/nitrocli that referenced this issue Apr 4, 2020
This patch implements the list command that lists all attached Nitrokey
devices.  Currently the Nitrokey Storage does not report its serial
number during HID enumeration, see [0].  So if we detect a Nitrokey
Storage device, we connect to it and use the get_serial_number function
to query its serial number.  This can be disabled using the --no-connect
option.

Note that even the get_serial_number function reports a wrong serial
number for the Nitrokey Storage, see [1].

[0] Nitrokey/nitrokey-storage-firmware#88
[1] Nitrokey/nitrokey-storage-firmware#76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants