Commit 0581511
committed
fix: guard RsaUnPad_PSS masking when bits==0
When the RSA modulus bit count is congruent to 1 mod 8 (e.g. a 2041-bit
or 3073-bit key), (mp_count_bits(n) - 1) & 0x7 == 0, so the leading
zero byte has already been consumed and the pointer advanced. In that
case (1<<0)-1 == 0, zeroing tmp[0] and pkcsBlock[0] and corrupting
maskedDB[0] before the XOR separator comparison.
RsaPad_PSS guards the equivalent step with 'if (hiBits)'. Add the same
guard to RsaUnPad_PSS.
Standard power-of-two key sizes (1024, 2048, 4096-bit) are unaffected
as their bit counts give bits==7 after the recomputation. The bug
affects non-standard key sizes loaded from external DER where
mp_count_bits(n) % 8 == 1.1 parent c4c71ee commit 0581511
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1882 | 1882 | | |
1883 | 1883 | | |
1884 | 1884 | | |
1885 | | - | |
1886 | | - | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
1887 | 1894 | | |
1888 | 1895 | | |
1889 | 1896 | | |
| |||
0 commit comments