PrecomputedValues::zeroize skips qinv (and BoxedMontyForm::zeroize skips its prime p params)
Maintainer antworten meist innerhalb von 1 Tag
@aviralgarg05 arbeitet bereits daran.
Seit 28.11.2026.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- Ein halber Tag
- Anfängerfreundlichkeit
- 65/100
Rechercherichtung
Start in src/private_key.rs:114-120 at PrecomputedValues and its Zeroize impl, then trace every use of qinv to see what a type change would affect. Read BoxedMontyForm::zeroize and BoxedMontyParams in crypto-bigint 0.7.11 to understand why the parameters survive; compare storing qinv as a BoxedUint. Done means dropping a PrivateKey wipes the inverse and any owned p parameters, with RSA tests still passing.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
In rsa 0.10.0, PrecomputedValues::zeroize (src/private_key.rs:114-120) wipes p, q, dp, and dq, but omits qinv:
pub(crate) struct PrecomputedValues {
pub(crate) p: SecretPrime,
pub(crate) q: SecretPrime,
pub(crate) dp: BoxedUint,
pub(crate) dq: BoxedUint,
pub(crate) qinv: BoxedMontyForm,
}
impl Zeroize for PrecomputedValues {
fn zeroize(&mut self) {
self.p.zeroize();
self.q.zeroize();
self.dp.zeroize();
self.dq.zeroize();
}
}
When a PrivateKey is dropped, $q^{-1} \bmod p$ remains unzeroized in freed heap memory.
Adding self.qinv.zeroize() alone does not wipe the associated parameters either. In crypto-bigint 0.7.11 (src/modular/boxed_monty_form.rs:229-235), BoxedMontyForm::zeroize wipes montgomery_form and skips params:
/// NOTE: This zeroizes the value, but _not_ the associated parameters!
#[cfg(feature = "zeroize")]
impl Zeroize for BoxedMontyForm {
fn zeroize(&mut self) {
self.montgomery_form.zeroize();
}
}
Because qinv is constructed with p_params (BoxedMontyForm::new clones BoxedMontyParams for the secret prime p), and BoxedMontyParams does not zeroize on drop, a separate copy of p (along with one, r2, and mod_inv) is also freed without being wiped. Storing qinv as a BoxedUint (or zeroizing owned BoxedMontyForm parameters on drop) would clear both.
- Vorherrschende Sprache
- Rust
- Sterne
- 678
- Forks
- 199
- Ø Merge
- 1 Std. 55 Min.
- Gemergte PRs (30 T.)
- 48
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus RustCrypto/RSA
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
RustCrypto/RSA#508 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bring back zeroizationOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
RustCrypto/RSA#507 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
RustCrypto/RSA#423 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
RustCrypto/RSA#364 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
RSA-KEM supportOffen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
RustCrypto/RSA#323 · 3 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
The new tests repeat each other and one only checks a two-line helperEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offeninfra
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
storytold/wordcraft#9405 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
in-progress
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
area: ai-assistants documentation help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
BetaBots-LLC/latticegate#17 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 94/100
storytold/craft-libs#5594 ·
Maintainer antworten meist innerhalb von 1 Tag
-
available documentation good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Nixitov/Riptide-Native#932 ·
Maintainer antworten meist innerhalb von 1 Tag