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_STATUS command reports wrong firmware version and serial number #96

Open
robinkrahl opened this issue Jan 5, 2020 · 0 comments
Open

Comments

@robinkrahl
Copy link

For my Nitrokey Storage, GET_STATUS reports the serial number 0 and firmware version 0.1, whereas GET_DEVICE_STATUS reports the serial number 327680 and firmware version 0.53 (although the serial number isn’t correct either, see #76).

Example code:

#include <stdio.h>
#include <stdlib.h>
#include <NK_C_API.h>

int main(void)
{
	int err = NK_login_auto();
	if (err == 0) {
		fprintf(stderr, "Could not connect to Nitrokey.\n");
		return 1;
	}

	NK_set_debug(true);

	struct NK_status status = {};
	err = NK_get_status(&status);
	if (err != 0) {
		fprintf(stderr, "Could not get status: %d\n", err);
		return 1;
	}

	struct NK_storage_status storage_status = {};
	err = NK_get_status_storage(&storage_status);
	if (err != 0) {
		fprintf(stderr, "Could not get storage status: %d\n", err);
		return 1;
	}

	return 0;
}

Log excerpts:

Command ID:	GET_STATUS hex: 0
Payload:
firmware_version:	[1]	01 00 -- -- -- -- -- -- -- -- -- -- -- -- -- --   ..
card_serial_u32:	0
card_serial:	00 00 00 00 -- -- -- -- -- -- -- -- -- -- -- --   ....
general_config:	ff ff ff 00 00 -- -- -- -- -- -- -- -- -- -- --   .....
numlock:	ff
capslock:	ff
scrolllock:	ff
enable_user_password:	0
delete_user_password:	0
Command ID:	GET_DEVICE_STATUS hex: 2e
 (int) versionInfo.major:	0
 (int) versionInfo.minor:	53
 (int) versionInfo.build_iteration:	0
 ActiveSmartCardID_u32:	327680
robinkrahl added a commit to robinkrahl/libnitrokey that referenced this issue Jan 5, 2020
As described in this issue [0], the GET_STATUS command does not work for
the Nitrokey Storage.  Therefore, NitrokeyManager::get_status does not
work either.  To fix this, we additionally execute the GET_DEVICE_STATUS
command if a Nitrokey Storage is detected to determine the serial number
and the firmware version.  This also fixes the failing test
test_get_status that we introduced in the last patch.

Fixes Nitrokey#166.

[0] Nitrokey/nitrokey-storage-firmware#96
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

1 participant