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

NFC: Split internal bigint module into submodules #1641

Merged
merged 7 commits into from
Sep 14, 2023
Merged

Conversation

briansmith
Copy link
Owner

The primary goal of this change is to make progress towards a better arithmetic API that abstracts over the storage (BoxedLimbs, etc.) to better facilitate doing more arithmetic in Rust instead of C, and to reduce the amount of heap allocation done for RSA operations.

The secondary goal is to unblock the merge of the most recent BoringSSL changes into ring. This is an issue only accidentally due to the timing of when I last merged BoringSSL into ring vs. when I made these changes.

@briansmith briansmith self-assigned this Sep 12, 2023
Clarify that `Nonnegative` values are immutable by enforcing this
through the module system.

Some read-only to-be-refactored-away methods of `Nonnegative` stay in
`bigint` to avoid moving them back-and-forth later.

`git diff HEAD^1:src/arithmetic/bigint.rs src/arithmetic/nonnegative.rs`
Better encapsulate `PrivateExponent` and enforce its immutability.

`git diff HEAD^1:src/arithmetic/bigint.rs src/arithmetic/bigint/private_exponent.rs`
Better encapsulate `Modulus` and `PartialModulus`.

`git diff HEAD^1:src/arithmetic/bigint.rs src/arithmetic/bigint/modulus.rs`
Ensure all the functions responsible for maintaining invariants for
`Modulus` values are within `Modulus`.

Clarify the constraints on the relationship between the moduli in
`Modulus::from_elem`.
`git diff HEAD^1:src/arithmetic/bigint.rs src/arithmetic/bigint/n0.rs`
When constructing a `PrivateExponent` we enforce that the exponent is
appropriately-sized for its associated modulus; this check is relied on
in RSA private key construction for key component consistency checks.

However, once the `PrivateExponent` is constructed there is no reason
to relate its value to the modulus. Doing so has inhibited us from
using some test vectors that are in the BoringSSL test suite. Further
this usage blocks encapsulating `BoxedLimbs` into its own submodule.
`git diff HEAD^1:src/arithmetic/bigint.rs src/arithmetic/bigint/boxed_limbs.rs`
@codecov
Copy link

codecov bot commented Sep 12, 2023

Codecov Report

Merging #1641 (90e16dd) into main (f8ea782) will increase coverage by 0.01%.
The diff coverage is 99.39%.

@@            Coverage Diff             @@
##             main    #1641      +/-   ##
==========================================
+ Coverage   92.21%   92.22%   +0.01%     
==========================================
  Files         127      132       +5     
  Lines       18821    18856      +35     
  Branches      196      196              
==========================================
+ Hits        17355    17390      +35     
  Misses       1430     1430              
  Partials       36       36              
Files Changed Coverage Δ
src/arithmetic/bigint/private_exponent.rs 95.65% <95.65%> (ø)
src/arithmetic/bigint/modulus.rs 99.35% <99.35%> (ø)
src/arithmetic/bigint.rs 99.23% <100.00%> (+<0.01%) ⬆️
src/arithmetic/bigint/boxed_limbs.rs 100.00% <100.00%> (ø)
src/arithmetic/bigint/n0.rs 100.00% <100.00%> (ø)
src/arithmetic/nonnegative.rs 100.00% <100.00%> (ø)
src/rsa/keypair.rs 96.59% <100.00%> (+0.03%) ⬆️

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

@briansmith briansmith merged commit 3bd30bb into main Sep 14, 2023
@briansmith briansmith deleted the b/bigint-split-1 branch September 14, 2023 18:15
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