From 113f799ec7d1728f0a5d7ab5b0e3b42e3de56407 Mon Sep 17 00:00:00 2001 From: djm <> Date: Thu, 3 Nov 2011 02:32:23 +0000 Subject: import OpenSSL 1.0.0e --- src/lib/libcrypto/ecdsa/ecs_ossl.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/lib/libcrypto/ecdsa/ecs_ossl.c') diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index 551cf5068f..1bbf328de5 100644 --- a/src/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/src/lib/libcrypto/ecdsa/ecs_ossl.c @@ -144,6 +144,14 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, } while (BN_is_zero(k)); + /* We do not want timing information to leak the length of k, + * so we compute G*k using an equivalent scalar of fixed + * bit-length. */ + + if (!BN_add(k, k, order)) goto err; + if (BN_num_bits(k) <= BN_num_bits(order)) + if (!BN_add(k, k, order)) goto err; + /* compute r the x-coordinate of generator * k */ if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) { -- cgit v1.2.3-55-g6feb