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

Multipacket handling for credentials listing and other improvements #24

Merged
merged 9 commits into from
Feb 3, 2023

Conversation

szszszsz
Copy link
Member

@szszszsz szszszsz commented Jan 18, 2023

Changes:

  • Use smaller buffers for the EncryptedDataContainer crypto fields, to save stack.
  • Handle multipacket responses, specifically for listing the credentials.
  • Use read-only state access where possible, to limit writes.

Fixes #19
Fixes #14

@szszszsz szszszsz force-pushed the state-encryption-smaller-buffer branch from 5df4632 to 9580018 Compare January 20, 2023 14:19
Load tests counters: 425 RW before, 421 RO / 4 RW now
Handle injected key writing error
Show error on failed write
Abort if the previous state is not set.
Try to clean up after Credential's write failure.
Using 0x61FF, as we do not know the count of the remaining bytes.
Fill the buffer as long as it is possible, break otherwise.
Instead of using a temporary buffer for the unfit data, reiterate over directories again -
this saves memory at the cost of the additional computation.
@szszszsz szszszsz force-pushed the state-encryption-smaller-buffer branch 2 times, most recently from 1631dfd to 314f8e5 Compare January 24, 2023 17:45
@szszszsz szszszsz force-pushed the state-encryption-smaller-buffer branch from 314f8e5 to 98c8b01 Compare January 24, 2023 17:47
@szszszsz szszszsz marked this pull request as ready for review January 24, 2023 17:48
@szszszsz szszszsz added the enhancement New feature or request label Jan 25, 2023
@szszszsz szszszsz changed the title Use smaller buffers for the EncryptedDataContainer crypto details Multipacket handling for credentials listing and other improvements Jan 25, 2023
@szszszsz
Copy link
Member Author

@robin-nitrokey Friendly ping!

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! I’m not sure if I understand the role of the SendRemaining command though. Currently it has the same effect as calling ListCredentials (unless there is no cached state), right? Wouldn’t it make more sense if ListCredentials would start at zero and only SendRemaining would use the cached state? Alternatively, an optional offset could be added to ListCredentials directly.

src/state.rs Show resolved Hide resolved
src/state.rs Show resolved Hide resolved
@szszszsz szszszsz merged commit 98c8b01 into main Feb 3, 2023
@szszszsz szszszsz deleted the state-encryption-smaller-buffer branch February 3, 2023 08:42
@szszszsz
Copy link
Member Author

szszszsz commented Feb 3, 2023

Regarding the SendRemaining - yes, that makes sense. Sequential calls to ListCredentials should not continue from the last point.
I have addressed that in 2be7cb2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write state only if changed State loading can crash
2 participants