impl Zeroize for BoxedMontyParams - #1338
Conversation
The intent is to add support for zeroize on RSA's qinv. BoxedMontyParams got placed in an Arc in RustCrypto#1143 but I'm not sure I follow the reason why. To implement Zeroize, this changes remove the Arc. The content is still placed on the heap (There is an underlying BoxedUint).
|
Let's make that a draft until we can figure out the reasoning behind Arc. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1338 +/- ##
==========================================
- Coverage 91.06% 91.05% -0.02%
==========================================
Files 189 189
Lines 22654 22651 -3
==========================================
- Hits 20630 20624 -6
- Misses 2024 2027 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
That said we do generally try to make use of in-place operations to avoid heap allocations whenever possible. See also previous discussion of this in #708 |
|
A potential alternative here could be to expose the equivalent of Someone wanting to write a |
| /// are both chosen at runtime. | ||
| #[derive(Clone, Eq, PartialEq)] | ||
| pub struct BoxedMontyParams(Arc<MontyParams<crate::uint::boxed::BoxedUint>>); | ||
| pub struct BoxedMontyParams(MontyParams<crate::uint::boxed::BoxedUint>); |
There was a problem hiding this comment.
This defeats the point of having a newtype at all. If we're not using the Arc then this should just be:
| pub struct BoxedMontyParams(MontyParams<crate::uint::boxed::BoxedUint>); | |
| pub type BoxedMontyParams = MontyParams<crate::uint::boxed::BoxedUint>; |
The intent is to add support for zeroize on RSA's precomputed p_params and q_params.
BoxedMontyParams got placed in an Arc in #1143 but I'm not sure I follow the reason why.
To implement Zeroize, this changes remove the Arc. The content is still placed on the heap (There is an underlying BoxedUint).