summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorHeiko Stuebner <[email protected]>2020-07-07 22:57:26 +0200
committerTom Rini <[email protected]>2020-07-08 17:21:46 -0400
commit49d0ea3746cae267b4f3c60c0e2e73dcac3d3213 (patch)
tree25566beb1ca5919d3ef4bd04e73e9bacb677ac0e /include/linux
parent8434b4373058018ee5b79f06f2cafd6b7c0c15e1 (diff)
lib: rsa: fix allocated size for rr and rrtmp in rsa_gen_key_prop()
When calculating rrtmp/rr rsa_gen_key_prop() tries to make (((rlen + 31) >> 5) + 1) steps in the rr uint32_t array and (((rlen + 7) >> 3) + 1) / 4 steps in uint32_t rrtmp[] with rlen being num_bits * 2 On a 4096bit key this comes down to to 257 uint32_t elements in rr and 256 elements in rrtmp but with the current allocation rr and rrtmp only have 129 uint32_t elements. On 2048bit keys this works by chance as the defined max_rsa_size=4096 allocates a suitable number of elements, but with an actual 4096bit key this results in other memory parts getting overwritten. So as suggested by Heinrich Schuchardt just use the actual bit-size of the key as base for the size calculation, in turn making the code compatible to any future keysizes. Suggested-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]> Reviewed-by: Simon Glass <[email protected]> rrtmp needs 2 + (((*prop)->num_bits * 2) >> 5) array elements. Reviewed-by: Heinrich Schuchardt <[email protected]>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions