Don't assume shared key length matches expected length
authorDr. Stephen Henson <steve@openssl.org>
Fri, 6 Oct 2017 23:04:17 +0000 (00:04 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 12 Oct 2017 01:40:30 +0000 (02:40 +0100)
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4485)

test/evp_test.c

index b08114e827c2069335ed66fe7ab85e32b3747dd5..265a4c3dd40e5f07be698b967541114b3f9160e5 100644 (file)
@@ -1228,7 +1228,10 @@ static int pderive_test_run(EVP_TEST *t)
     unsigned char *got = NULL;
     size_t got_len;
 
-    got_len = expected->output_len;
+    if (EVP_PKEY_derive(expected->ctx, NULL, &got_len) <= 0) {
+        t->err = "DERIVE_ERROR";
+        goto err;
+    }
     if (!TEST_ptr(got = OPENSSL_malloc(got_len))) {
         t->err = "DERIVE_ERROR";
         goto err;