Don't assume shared key length matches expected length

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4485)
This commit is contained in:
Dr. Stephen Henson 2017-10-07 00:04:17 +01:00
parent d59d853a6f
commit 9b82c8b1c1

View file

@ -1228,7 +1228,10 @@ static int pderive_test_run(EVP_TEST *t)
unsigned char *got = NULL; unsigned char *got = NULL;
size_t got_len; 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))) { if (!TEST_ptr(got = OPENSSL_malloc(got_len))) {
t->err = "DERIVE_ERROR"; t->err = "DERIVE_ERROR";
goto err; goto err;