Merge pull request #3266 from dgarske/unit_test

Fix for DH compute key compatibility function failure
This commit is contained in:
toddouska
2020-09-02 10:23:23 -07:00
committed by GitHub
3 changed files with 8 additions and 3 deletions

View File

@ -29811,6 +29811,8 @@ int wolfSSL_DH_compute_key(unsigned char* key, WOLFSSL_BIGNUM* otherPub,
XFREE(priv, NULL, DYNAMIC_TYPE_PRIVATE_KEY);
#endif
WOLFSSL_LEAVE("wolfSSL_DH_compute_key", ret);
return ret;
}

View File

@ -27726,7 +27726,7 @@ static void test_wolfSSL_X509_sign(void)
byte sn[16];
int snSz = sizeof(sn);
printf(testingFmt, "wolfSSL_X509_sign\n");
printf(testingFmt, "wolfSSL_X509_sign");
/* Set X509_NAME fields */
AssertNotNull(name = X509_NAME_new());
@ -32751,6 +32751,7 @@ static void test_wolfSSL_OCSP_get0_info()
static void test_wolfSSL_EVP_PKEY_derive(void)
{
#ifdef OPENSSL_ALL
printf(testingFmt, "wolfSSL_EVP_PKEY_derive()");
#if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2))
EVP_PKEY_CTX *ctx;
unsigned char *skey;
@ -32800,6 +32801,7 @@ static void test_wolfSSL_EVP_PKEY_derive(void)
XFREE(skey, NULL, DYNAMIC_TYPE_OPENSSL);
#endif /* HAVE_ECC */
#endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */
printf(resultFmt, "passed");
#endif /* OPENSSL_ALL */
}

View File

@ -1385,8 +1385,9 @@ int wolfSSL_EVP_PKEY_derive(WOLFSSL_EVP_PKEY_CTX *ctx, unsigned char *key, size_
if (*keylen < (size_t)len) {
return WOLFSSL_FAILURE;
}
/* computed DH agreement can be less than DH size if leading zeros */
if (wolfSSL_DH_compute_key(key, ctx->peerKey->dh->pub_key,
ctx->pkey->dh) != len) {
ctx->pkey->dh) <= 0) {
return WOLFSSL_FAILURE;
}
}