rsa: fix rsa_gen_key_prop() buffer-sizing and zero-modulus handling
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 4 repliesIn review
- v11 patch 1 replySuperseded
Changes in v2 from the cover letter
- Patch 1: use DIV_ROUND_UP() instead of open-coded rounding for the n[]/rr[] allocation sizes.
- Patch 2: new, addressing the num_bits == 0 case.
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | rsa: fix undersized modulus buffers in rsa_gen_key_prop()lib/ | +4 | 0 replies | |
| 2/2 | rsa: reject zero-bit modulus in rsa_gen_key_prop()lib/ | +4 | 1 reply |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Simon Glass |
|---|---|
| 1/2 | R-b |
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/2] rsa: fix rsa_gen_key_prop() buffer-sizing and zero-modulus handling
Fix two memory issues in rsa_gen_key_prop():
- Correct n[]/rr[] sizing to prevent out-of-bounds writes.
- Reject all-zero modulus to prevent out-of-bounds reads.
Changes in v2:
- Patch 1: use DIV_ROUND_UP() instead of open-coded rounding for the n[]/rr[] allocation sizes.
- Patch 2: new, addressing the num_bits == 0 case.
UT:
Sandbox:
=> ut lib lib_rsa_keyprop_oob
Test: lib_rsa_keyprop_oob: rsa.crsa_gen_key_prop: n_sz=258 leading_zeros=1 stripped_bytes=257 num_bits=2056rsa_gen_key_prop: n_words=66 rr_words=130 rrtmp_words=130 n=000000001c135890 rr=000000001c1359a0 rrtmp=000000001c135bb0 (FIXED sizing)rsa_gen_key_prop: br_i32_decode(n) done, n[0] (bit_length)=2056 n0inv_input n[1]=0x968b6a4drsa_gen_key_prop: rlen=4112 rr zero-init loop wrote indices 1..129rsa_gen_key_prop: br_i32_reduce(rr) done, rr[0] (bit_length)=2056 Tests run: 1, 0 ms, average: 0 ms, failures: 0
=> ut lib lib_rsa_keyprop_zero_modulus
Test: lib_rsa_keyprop_zero_modulus: rsa.crsa_gen_key_prop: n_sz=3 leading_zeros=3 num_bits=0, rejecting (-EINVAL) Tests run: 1, 0 ms, average: 0 ms, failures: 0
=>
Prasad Kummari (2):
rsa: fix undersized modulus buffers in rsa_gen_key_prop()
rsa: reject zero-bit modulus in rsa_gen_key_prop()
lib/rsa/rsa-keyprop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0