-
Notifications
You must be signed in to change notification settings - Fork 10
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
Check PWS slot status before accessng it #77
Conversation
a3c8e6c
to
411622a
Compare
Do you see what causes the checks to fail? Everything’s working fine on my machine, and I don’t see any error message in the cargo output. |
I hit that a few times in the past. I believe it's due to the build taking too much memory (that may have increased over time) and being killed (at least that's what a quick search suggested). I plan to check on how to increase the memory size of the runner and see if that helps. |
Thanks for this patch! I'll review this pull request tomorrow. I have two preliminary thoughts, though:
|
1) Can we add a test?
If the slot is empty, the nitrokey crate already returns an error (and
we have a nitrocli test case for that). The interesting test case would
be after a factory reset as the slot status is reset, but the slot
content is not cleared. (We could actually open a separate issue for
that.) But I don’t want to add that test case until the problems with
the factory reset are fixed (or we know a workaround).
2) Should we add a change log entry?
Done. Let’s see if the Gitlab build error persists.
|
Turns out it is overwritten with random data. Anyway, it’s not emptied. |
I'd want to go ahead and merge the factory reset code. I believe then we should add a test along with the check-in. I easily reproduced the issue:
and was able to verify that it does work with the fix. So this is a perfect candidate, from my point of view.
Thanks! |
The |
The Nitrokey devices to not check whether a PWS slot is programmed before accessing it (upstream issues [0] [1]). Until this is fixed in the firmware, we have to manually check the slot status in nitrocli pws get. This could have been done in libnitrokey or the nitrokey crate, yet this would lead to unnecessary commands if we check multiple fields of a slot at the same time. [0] Nitrokey/nitrokey-pro-firmware#56 [1] Nitrokey/nitrokey-storage-firmware#81
The factory reset only clears the slot status. The slot content is overwritten with random data. Therefore accessing a PWS slot after a factory reset returns garbage data. We fixed this by always querying the status before accessing the PWS. This patch adds a corresponding test case.
Done! |
I checked the two failures that I found and saw no similarities: Different runner and failures in different stages of the build. All I can say right now is that if you see this error again feel free to ignore it. I will test the change locally in all likely hood and can retry the job if it failed after check-in. That's not really a satisfactory state, but given the few failures we have it hopefully won't be a big burden either.
Thanks, I'll hopefully merge it soon! |
Hm. I just hit this problem:
in the fourth run of the test. Superficially this could be another timing problem of sorts. But it could also come from somewhere else. |
Hm, cannot reproduce on the Storage. :/ |
I merged the change after seeing another 53 successful runs and brief double check of the code in question. We'll see whether we hit it again. Thanks for this fix, Robin! |
Have you asked for a Pro device for testing? I would say it would be very helpful and Jan seemed happy to provide hardware that is needed. |
Not yet. I first wanted to consider the option of using a development board together with a smart card to simulate a Pro (that I then could also use for firmware testing). But I have to think a bit more about that. |
The Nitrokey devices to not check whether a PWS slot is programmed
before accessing it (upstream issues [0] [1]). Until this is fixed in
the firmware, we have to manually check the slot status in nitrocli pws
get. This could have been done in libnitrokey or the nitrokey crate,
yet this would lead to unnecessary commands if we check multiple fields
of a slot at the same time.
[0] Nitrokey/nitrokey-pro-firmware#56
[1] Nitrokey/nitrokey-storage-firmware#81