-
Notifications
You must be signed in to change notification settings - Fork 27
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
Admin app se050 test #335
Admin app se050 test #335
Conversation
d42fcad
to
38cef33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it still make sense to include the random bytes backend if we can’t use it together with the tests anyway?
I left the random bytes backend since the boilerplate to get the se050 passed to a backend is useful (as it will be part of a backend in the end, not an app). |
I left the random bytes backend because the boilerplate to get the se050 passed to a backend is useful (as it will be part of a backend in the end, not an app). |
87e8fa7
to
12481bf
Compare
5c24adf
to
1ac519c
Compare
This PR has evolved a bit. Now it adds the admin app tests and a barebones SE050 backend that:
It also feeds some entropy from the SE050 in the initial Rng seed for the nrf52 runner. |
fb7e70c
to
d0d124e
Compare
@robin-nitrokey if you can test this on LPC55 (including that |
@robin-nitrokey have you had time to test this on NFC? |
Not yet, I’ll try to do so today or tomorrow morning. |
The boot process over USB works fine, but the
|
I see where this error comes from. You need to enable the There are 2 features added with this PR:
Sorry I should have documented that in the PR. |
The |
Argh, I just assumed those would be activated by the Unfortunately, even SE050 initialization does not work. If I enable just the When running with gdb, it hangs at: self.t1.resync()?; let data = self.receive_data(&mut [])?; let read = self.read(&mut header_buffer); match self.twi.read(self.se_address, buffer) { while self.i2c.stat.read().mstpending().is_in_progress() {} Though this has to be taken with a grain of salt as I previously experienced timing issues when debugging I2C communication, so the actual problem could be somewhere else. Do you have any ideas what could be the problem or should I try to debug it? |
As a benchmark, I executed the hardware tests from the main branch. I did not run into this issue, even when debugging with |
I did some more tests. Removing the RESYNC command in Running the SE050 tests with
Edit: Looks like this is not related to gdb. I tried again without gdb and it also timed out. |
But FIDO operations no longer work if
Without |
If this can't be done quickly, I think we might want to merge and add a increase timeout for the NFC version, or reduce the total number of tests. Some tests are probably a bit overkill for in-the-field testing, though they were necessary for development of the driver. For example reducing RSA tests should be significant. |
That’s fine with me. For fixing the problem, the next steps could be:
|
I would also prefer to not have this PR be blocked by this issue entirely. To fix that I would suggest to:
|
I updated the tests with reduced testing. It should still test most important features and detect unstable behaviour. I also bumped the timeout on the nitropy side. |
Just to see whether changing the configured data rate does make a difference, I tried to time the RESYNC operation writes in let command = [0x5a, 0xc0, 0x00, 0xff, 0xfc];
i2c.write(0x48, &command)
.expect("failed to send RESYNC command"); I consistently get an execution time of ca. 570 µs with the 100 kHz setting and 155 µs with 400 kHz. Of course this is not really a reliable measurement, but the settings do seem to have an effect and even the proportions of 1:4 roughly match. |
And what happens with the |
Basically the same. 570 µs vs 150 µs. |
With 7021fd3 and Nitrokey/pynitrokey@f7f507e I get execution times of 8 s, 13 s, 14 s and 21 s. So still quite a big variation but overall much faster and not close to the timeout. |
Great then. I suppose we can merge this and Nitrokey/pynitrokey#423 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add se050
and se050-test-app
to the test
feature so that we can tick that box?
to be removed |
runners/embedded/src/bin/app-nrf.rs
Outdated
use chacha20::ChaCha8Rng; | ||
use rand::Rng as _; | ||
let mut dev_rng = Rng::new(ctx.device.RNG); | ||
let seed: [u8; 32] = dev_rng.gen(); | ||
#[cfg(feature = "se050")] | ||
let mut se050 = se05x::se05x::Se05X::new(twim, 0x48, se050_timer); | ||
|
||
#[cfg(feature = "se050")] | ||
let seed = (|| { | ||
use se05x::se05x::commands::GetRandom; | ||
se050.enable()?; | ||
let buf = &mut [0; 100]; | ||
let se050_rand = se050.run_command(&GetRandom { length: 32.into() }, buf)?; | ||
let mut s: [u8; 32] = se050_rand | ||
.data | ||
.try_into() | ||
.or(Err(se05x::se05x::Error::Unknown))?; | ||
for (se050, orig) in s.iter_mut().zip(seed) { | ||
*se050 ^= orig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be moved to a helper method in lib.rs
to be shared between both socs.
Some thoughts during debugging:
|
TWI is the term used by the NRF peripheral that drives its I2C bus. So yes I2C would be more general.
Right, that would be great. But for everything to type check the the backend needs to be always be created. Creating it without the se05x would be tricky. Maybe I can implement the backend and extension traits for This would mean that it is impossible to perform any operation for clients that use the SE050 backend. We could be more granular and return |
Couldn’t we store an |
Dispatch seems like a good place indeed. I would rather not return |
Can you please rebase onto main for a final round of tests? |
Also, the CI cannot find the webcrypt dependency:
Although I’m not sure why because the commit seems to exist: sosthene-nitrokey/nitrokey-webcrypt-rust@32240f8 Maybe just merge and tag Nitrokey/nitrokey-websmartcard-rust#9? |
Tests appear fine on the nk3am |
Works for me:
RSA-2048 key generation with OpenPGP also works for me with this branch.
|
Thanks! So from my POV, the remaining blockers are:
|
3f2d929
to
7935733
Compare
This PR adds a test for the admin app in the SE050.
Linked nitropy PR: Nitrokey/pynitrokey#423
Linked admin-app PR: Nitrokey/admin-app#5