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

poly1305 internals: Remove unneeded I-U-F buffering. #2270

Closed
wants to merge 1 commit into from

Conversation

briansmith
Copy link
Owner

CRYPTO_poly1305_update was designed to buffer any partial blocks, only passing full blocks to poly1305_update. Then
CRYPTO_poly1305_finish would pass in the final partial block.

chacha20_poly1305's poly1305_update_padded_16 was working around that logic to ensure that a partial block never got buffered. Then it was doing extra work to pad the last block with zeros.

These two mechanisms were basically cancelling each other out. Instead, just avoid all the work.

This removes some non-trivial buffer management from C.

`CRYPTO_poly1305_update` was designed to buffer any partial blocks,
only passing full blocks to poly1305_update. Then
`CRYPTO_poly1305_finish` would pass in the final partial block.

`chacha20_poly1305`'s poly1305_update_padded_16 was working around that
logic to ensure that a partial block never got buffered. Then it was
doing extra work to pad the last block with zeros.

These two mechanisms were basically cancelling each other out. Instead,
just avoid all the work.

This removes some non-trivial buffer management from C.
@briansmith briansmith self-assigned this Jan 22, 2025
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.

Project coverage is 91.11%. Comparing base (a1c4623) to head (0b1967e).

Files with missing lines Patch % Lines
src/aead/chacha20_poly1305/mod.rs 0.00% 5 Missing ⚠️
src/aead/poly1305.rs 88.88% 0 Missing and 1 partial ⚠️

❗ There is a different number of reports uploaded between BASE (a1c4623) and HEAD (0b1967e). Click for more details.

HEAD has 16 uploads less than BASE
Flag BASE (a1c4623) HEAD (0b1967e)
26 10
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2270      +/-   ##
==========================================
- Coverage   96.75%   91.11%   -5.64%     
==========================================
  Files         169      159      -10     
  Lines       20837    15311    -5526     
  Branches      496      427      -69     
==========================================
- Hits        20161    13951    -6210     
- Misses        571     1248     +677     
- Partials      105      112       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@briansmith
Copy link
Owner Author

This requires some other changes first.

@briansmith briansmith closed this Jan 22, 2025
@briansmith briansmith deleted the b/slicing branch January 22, 2025 18:29
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.

1 participant