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

EC: Use only array types when crossing Rust<->C boundary #1758

Merged
merged 2 commits into from
Oct 18, 2023
Merged

Conversation

briansmith
Copy link
Owner

Don't assume that a struct that contains only arrays has no padding, and don't assume we can cast between a P{256,384}_POINT and a Limb[3][P{256,384}_LIMBS] array.

@briansmith briansmith self-assigned this Oct 18, 2023
@briansmith
Copy link
Owner Author

@vkrasnov I don't know that this presently solves any problem but it is definitely safer to do it this way. I wrote this when trying to figure out what's wrong with your P-521 code on a 32-bit machine.

Better match the Rust declarations of these functions. Prepare to
support more target platforms and more weird things (like P-521) that
by avoiding any kind of alignment assumptions at the language
boundary (or elsewhere).
Avoid using the P384_POINT type on the C side. It seems to work for all
the targets we support, for P-384, but this pattern probably doesn't
work in general. Especially due to alignment issues for 32-bit targets,
it is doubtful it would work for P-521.
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #1758 (65af475) into main (9a49f37) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1758   +/-   ##
=======================================
  Coverage   96.00%   96.00%           
=======================================
  Files         138      138           
  Lines       20691    20751   +60     
  Branches      226      226           
=======================================
+ Hits        19864    19923   +59     
- Misses        790      792    +2     
+ Partials       37       36    -1     
Files Coverage Δ
crypto/fipsmodule/ec/ecp_nistz384.inl 100.00% <100.00%> (ø)
crypto/fipsmodule/ec/p256-nistz.c 96.73% <100.00%> (ø)
crypto/fipsmodule/ec/p256.c 99.65% <100.00%> (+0.03%) ⬆️
src/ec/suite_b/ops.rs 98.08% <100.00%> (ø)
src/ec/suite_b/ops/p384.rs 100.00% <ø> (ø)

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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