-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys/fido2: improve & simplify flash handling #21110
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
base: master
Are you sure you want to change the base?
sys/fido2: improve & simplify flash handling #21110
Conversation
771229a
to
8fdb7a6
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.
Thanks, some comments below. I'm not very familiar with the mtd API, maybe @benpicco could have a look as well?
sys/include/fido2/ctap/ctap_mem.h
Outdated
* | ||
* @param[in] key pointer to authenticator state | ||
* @param[in] rp_id_hash pointer to hash of rp domain string | ||
* @param[in] addr pointer to address where to read from | ||
* @param[in] absolute_offset pointer to a variable holding the total offset from the |
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.
the parameter is called off
in the implementation. Would be nice to align both.
From an API perspective, I would be nicer to have some iterator struct, that hides the offset information from the user.
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.
Sounds good, do you have an example for an iterator struct somewhere in RIOT ?
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.
@miri64 recommended nib-nc as an example:
https://github.com/RIOT-OS/RIOT/blob/master/sys/include/net/gnrc/ipv6/nib/nc.h#L300
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.
Thanks for the recommendation :) Updated the code to use an iterator-like struct
#include "debug.h" | ||
|
||
static mtd_dev_t *_mtd_dev; |
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.
static mtd_dev_t *_mtd_dev; | |
static mtd_dev_t *_mtd_dev = CONFIG_FIDO2_MTD_DEV; |
We should make the application select this
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.
Doing this I get:
/home/h0ps/Programming/RIOT/tests/sys/fido2_ctap_hid/bin/nrf52840dongle/riotbuild/riotbuild.h:21:30: error: initializer element is not constant
21 | #define CONFIG_FIDO2_MTD_DEV mtd_aux
| ^~~~~~~
Therefore I am setting _mtd_dev
inside fido2_ctap_mem_init
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.
Had another look, still no in-depth review I'm afraid. But at least some more comments below.
FEATURES_REQUIRED += periph_flashpage_aux | ||
CFLAGS += -DCONFIG_FIDO2_MTD_DEV=mtd_aux |
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.
Is this different to tests/sys/fido2_ctap/Makefile
on purpose?
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.
Nope it wasn't. Differentiating between native and any board in the Makefile now
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.
I guess you forgot a git push
?
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.
No, the change is in the fido2_ctap
Makefile since it has support for the native
target
790087f
to
1d6c51f
Compare
Contribution description
This PR tries to improve the flash handling done by the FIDO2 implementation. Specifically this entails:
mtd_aux
device to reserve flash memory for the FIDO2 data_flash_is_erased
function)mtd_flashpage
apiSince the AUX slot approach is integrated into the
mtd
API, which is the recommended method for working with flash, I wonder if theperiph_flashpage_in_address_space
feature I added to reserve flash memory for FIDO2 can now be deprecated ?@benpicco, with the
mtd_aux
approach, how can two different applications reserve flash memory without risking corruption of each other's data? Is it possible to divide the AUX slot into multiple smaller slots, that can be allocated for use by different applications?Testing procedure
/tests/sys/fido2_ctap
with bothnative
andnrf52840dk
as target/tests/sys/fido2_ctap_hid