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

Add dynamic estimation of remaining credential space #92

Merged
merged 7 commits into from
Aug 1, 2024

Conversation

sosthene-nitrokey
Copy link

@sosthene-nitrokey sosthene-nitrokey commented Jul 25, 2024

The estimation is pretty rough and in most cases pessimistic. It reserves multiple blocks of margin to prevent filling up the device.

With the default configuration of the usbip runner, it estimates the value to be around 40, and I could generate more than 60.

For now, this PR removes the hard-coded limitation when generating credentials.
This makes credential generation faster, but at the same time this could prove to be an issue when listing credential (even the USBIP version is pretty slow to list all credentials).

@sosthene-nitrokey sosthene-nitrokey force-pushed the dynamic-limit branch 3 times, most recently from 31aa18f to 4faae1b Compare July 25, 2024 14:14
@sosthene-nitrokey sosthene-nitrokey marked this pull request as ready for review July 31, 2024 13:07
@sosthene-nitrokey
Copy link
Author

This depends on trussed-dev/trussed-staging#27

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +393 to +396
>= self
.config
.max_resident_credential_count
.unwrap_or(MAX_RESIDENT_CREDENTIALS_GUESSTIMATE);
Copy link
Member

Choose a reason for hiding this comment

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

As we now always apply a hard limit, it would make sense to make the max_resident_credential_count configuration required and remove the guesstimate constant. This would also make the code easier to read.

src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@robin-nitrokey robin-nitrokey left a comment

Choose a reason for hiding this comment

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

LGTM.

Suggestions that can also be implemented in separate PRs:

  • require max_resident_credential_count config
  • add test case that reaches the credential limit
  • add test case with low remaining space

@sosthene-nitrokey sosthene-nitrokey merged commit 2113600 into main Aug 1, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

3 participants