1
0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2026-01-12 01:20:14 +00:00
Lukas Wunner b16510a530 crypto: ecdsa - Harden against integer overflows in DIV_ROUND_UP()
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>
2025-02-09 18:08:12 +08:00
..
2025-01-28 12:25:12 -08:00
2025-01-24 14:56:59 -08:00
2025-01-22 09:03:41 -08:00
2025-01-29 14:38:19 -08:00
2025-01-28 14:23:46 -08:00
2025-01-04 15:27:35 -07:00
2025-01-23 08:04:07 -08:00
2025-01-06 07:36:39 -07:00
2025-01-27 08:50:19 -08:00
2025-01-26 14:03:44 -08:00
2025-01-18 12:33:39 -08:00
2025-02-01 15:07:56 -08:00
2025-01-25 20:22:31 -08:00
2025-01-09 10:06:14 +01:00
2025-01-07 18:06:51 -08:00
2025-01-25 08:22:26 +00:00
2025-01-14 19:45:35 +01:00
2025-01-26 16:12:44 -08:00
2025-01-16 11:48:11 +01:00
2025-01-21 20:09:14 -08:00
2025-01-31 10:39:07 -08:00
2025-01-31 12:07:07 -08:00
2025-01-20 09:40:49 -08:00
2025-01-15 15:07:23 -08:00
2025-01-25 20:22:42 -08:00
2025-01-25 16:03:40 -08:00
2025-01-16 17:22:59 -08:00
2025-01-20 10:29:11 -08:00
2025-01-10 11:59:00 +01:00
2025-01-07 15:16:48 +01:00
2025-01-02 10:37:14 -06:00
2025-01-08 14:50:11 -08:00
2025-01-11 20:39:43 +01:00
2025-01-29 09:04:28 -08:00
2025-01-23 17:51:16 -08:00