File ECDSA_signatures_timing_attack.patch of Package compat-openssl098.16428

Index: openssl-0.9.8h/crypto/ecdsa/ecs_ossl.c
===================================================================
--- openssl-0.9.8h.orig/crypto/ecdsa/ecs_ossl.c
+++ openssl-0.9.8h/crypto/ecdsa/ecs_ossl.c
@@ -144,6 +144,16 @@ static int ecdsa_sign_setup(EC_KEY *ecke
 			}
 		while (BN_is_zero(k));
 
+#ifdef ECDSA_POINT_MUL_NO_CONSTTIME
+		/* 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;
+#endif /* def(ECDSA_POINT_MUL_NO_CONSTTIME) */
+
 		/* compute r the x-coordinate of generator * k */
 		if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx))
 		{
Index: openssl-0.9.8h/crypto/ocsp/ocsp_lib.c
===================================================================
--- openssl-0.9.8h.orig/crypto/ocsp/ocsp_lib.c
+++ openssl-0.9.8h/crypto/ocsp/ocsp_lib.c
@@ -169,14 +169,14 @@ int OCSP_parse_url(char *url, char **pho
 
 	char *host, *port;
 
-	/* dup the buffer since we are going to mess with it */
-	buf = BUF_strdup(url);
-	if (!buf) goto mem_err;
-
 	*phost = NULL;
 	*pport = NULL;
 	*ppath = NULL;
 
+	/* dup the buffer since we are going to mess with it */
+	buf = BUF_strdup(url);
+	if (!buf) goto mem_err;
+
 	/* Check for initial colon */
 	p = strchr(buf, ':');
 
openSUSE Build Service is sponsored by