briansmith / ring

Safe, fast, small crypto using Rust
Other
3.64k stars 682 forks source link

cpu: Reduce scope of `unsafe` and clarify safety properties. #2083

Closed briansmith closed 4 weeks ago

briansmith commented 4 weeks ago

Completely separate the storage of flags on a per-architecture basis, so that ARM/Aarch64 and x86/x86_64 code paths can begin to further diverge in how they handle CPU feature flags.

Reduce the scope of each of the static mut declarations to the minimum, and encapsulate the access to each in a minimal, safe internal API.

Within the implementations of those new internal APIs, use addr_of!/addr_of_mut! and ptr::{read,write} to access the static mut fields.

codecov[bot] commented 4 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.24%. Comparing base (d3f508b) to head (0b07a9e). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2083 +/- ## ======================================= Coverage 97.24% 97.24% ======================================= Files 144 144 Lines 19995 20022 +27 Branches 228 228 ======================================= + Hits 19444 19471 +27 Misses 525 525 Partials 26 26 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.