Commit 4da5150
Per @tarcieri's reply on #690:
> The fix for the logic is there, however it looks like the regression
test wasn't carried over and probably should be.
> As it were, the entire implementation diverged as we moved from
`num-bigint` to `crypto-bigint`.
The production fix lives on master already (`validate_private_key_parts`
rejects any `prime <= one` with `Error::InvalidPrime`,
src/key.rs:760-763). What was missing was the regression test added
alongside it in upstream commit `2926c91bef` (PR #624). This PR ports
just that test.
## Adaptations vs the original test
- **Type swap**: original used `num-bigint::BigUint` constructors
(`BigUint::from_u64`, `BigUint::zero()`); ported to
`crypto-bigint::BoxedUint::from(u64)` since that's what current master's
`from_components` API takes.
- **API path**: the original numeric inputs (`n=239, e=185, d=0,
primes=[1, 239]`) include an `e` below master's `MIN_PUB_EXPONENT`
bound, so the test calls `from_components_with_large_exponent` (gated
`#[cfg(feature = "hazmat")]`, matching the existing
`test_from_components_with_small_exponent` /
`test_from_components_with_large_exponent` neighbors) rather than
`from_components`. Ordering inside `validate_skip_exponent_size` ->
`validate_private_key_parts` still hits the `prime <= one` check first,
so we exercise exactly the path the original test did.
- **Assertion**: `Err(Error::InvalidPrime)` (not a panic) — same intent
as the original.
No production-code changes. Single-file diff in `src/key.rs`.
Refs: GHSA-9c48-w39g-hm26, #690, #624, upstream `2926c91bef`.
Co-authored-by: vulgraph <vulgraph@users.noreply.github.com>
1 parent e31a020 commit 4da5150
1 file changed
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1302 | 1302 | | |
1303 | 1303 | | |
1304 | 1304 | | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
1305 | 1329 | | |
0 commit comments