blob: db4fcfe2357ce7811ce3731dc03229f42130ca7b [file] [log] [blame]
developer29c4d2d2022-12-26 19:41:22 +08001From 54211caa2e0e5163aefef390daf88a971367a702 Mon Sep 17 00:00:00 2001
2From: Glenn Strauss <gstrauss@gluelogic.com>
3Date: Tue, 4 Oct 2022 17:09:24 -0400
4Subject: [PATCH 6/7] dpp_pkex: EC point mul w/ value < prime
5
6crypto_ec_point_mul() with mbedtls requires point
7be multiplied by a multiplicand with value < prime
8
9Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
10---
11 src/common/dpp_crypto.c | 4 +++-
12 1 file changed, 3 insertions(+), 1 deletion(-)
13
14--- a/src/common/dpp_crypto.c
15+++ b/src/common/dpp_crypto.c
developer505c9432023-05-12 18:58:17 +080016@@ -1588,7 +1588,9 @@ dpp_pkex_derive_Qr(const struct dpp_curv
developer29c4d2d2022-12-26 19:41:22 +080017 Pr = crypto_ec_key_get_public_key(Pr_key);
18 Qr = crypto_ec_point_init(ec);
19 hash_bn = crypto_bignum_init_set(hash, curve->hash_len);
20- if (!Pr || !Qr || !hash_bn || crypto_ec_point_mul(ec, Pr, hash_bn, Qr))
21+ if (!Pr || !Qr || !hash_bn ||
22+ crypto_bignum_mod(hash_bn, crypto_ec_get_prime(ec), hash_bn) ||
23+ crypto_ec_point_mul(ec, Pr, hash_bn, Qr))
24 goto fail;
25
26 if (crypto_ec_point_is_at_infinity(ec, Qr)) {