Files
linux-stable-mirror/include/linux
Lukas Wunner f2133b849f crypto: ecdsa - Harden against integer overflows in DIV_ROUND_UP()
commit b16510a530 upstream.

Herbert notes that DIV_ROUND_UP() may overflow unnecessarily if an ecdsa
implementation's ->key_size() callback returns an unusually large value.
Herbert instead suggests (for a division by 8):

  X / 8 + !!(X & 7)

Based on this formula, introduce a generic DIV_ROUND_UP_POW2() macro and
use it in lieu of DIV_ROUND_UP() for ->key_size() return values.

Additionally, use the macro in ecc_digits_from_bytes(), whose "nbytes"
parameter is a ->key_size() return value in some instances, or a
user-specified ASN.1 length in the case of ecdsa_get_signature_rs().

Link: https://lore.kernel.org/r/Z3iElsILmoSu6FuC@gondor.apana.org.au/
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-07-17 18:37:24 +02:00
..
2025-03-07 18:25:35 +01:00
2025-07-10 16:05:08 +02:00
2025-05-29 11:03:25 +02:00
2024-12-14 20:03:35 +01:00
2025-05-29 11:03:25 +02:00
2025-05-29 11:02:23 +02:00
2025-03-28 22:03:30 +01:00
2025-01-17 13:40:50 +01:00
2025-02-08 09:57:23 +01:00
2025-06-19 15:32:18 +02:00
2025-04-20 10:15:25 +02:00
2025-04-20 10:15:49 +02:00
2025-05-29 11:02:20 +02:00
2025-02-08 09:58:16 +01:00
2025-03-28 22:03:30 +01:00
2025-01-23 17:22:53 +01:00
2025-02-01 18:39:35 +01:00
2025-02-27 04:30:19 -08:00
2025-07-10 16:05:11 +02:00