8000 sys/fido2: improve & simplify flash handling by Ollrogge · Pull Request #21110 · RIOT-OS/RIOT · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Ollrogge
Copy link
Member

Contribution description

This PR tries to improve the flash handling done by the FIDO2 implementation. Specifically this entails:

  • Usage of mtd_aux device to reserve flash memory for the FIDO2 data
  • No more usage of functionality that requires flash to be memory-mapped (e.g. _flash_is_erased function)
  • Coherent usage of the mtd_flashpage api

Since the AUX slot approach is integrated into the mtd API, which is the recommended method for working with flash, I wonder if the periph_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 both native and nrf52840dk as target
  • /tests/sys/fido2_ctap_hid

@github-actions github-actions bot added Area: tests Area: tests and testing framework Area: sys Area: System labels Dec 25, 2024
@Ollrogge Ollrogge force-pushed the fido2_flash_handling_improvements branch from 771229a to 8fdb7a6 Compare December 26, 2024 18:15
@mguetschow mguetschow added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 28, 2025
@riot-ci
Copy link
riot-ci commented Jan 28, 2025

Murdock results

✔️ PASSED

1d6c51f fixup! sys/fido2: improve & simplify flash handling

Success Failures Total Runtime
10287 0 10287 09m:57s

Artifacts

Copy link
Contributor
@mguetschow mguetschow left a 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?

*
* @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
Copy link
Contributor

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.

Copy link
Member Author

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 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static mtd_dev_t *_mtd_dev;
static mtd_dev_t *_mtd_dev = CONFIG_FIDO2_MTD_DEV;

We should make the application select this

Copy link
Member Author

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

Copy link
Contributor
@mguetschow mguetschow left a 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.

Comment on lines +23 to +24
FEATURES_REQUIRED += periph_flashpage_aux
CFLAGS += -DCONFIG_FIDO2_MTD_DEV=mtd_aux
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

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?

1E0A
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0