forked from wolfSSL/wolfssl
Fix build error with missing bio
. Fix for pkey
not being reset to NULL for d2i_PrivateKey
failure case test.
This commit is contained in:
16
tests/api.c
16
tests/api.c
@ -15690,6 +15690,7 @@ static void test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
(!defined(NO_RSA) || defined(HAVE_ECC)) && \
|
(!defined(NO_RSA) || defined(HAVE_ECC)) && \
|
||||||
defined(USE_CERT_BUFFERS_2048)
|
defined(USE_CERT_BUFFERS_2048)
|
||||||
|
|
||||||
|
BIO* bio = NULL;
|
||||||
EVP_PKEY* pkey = NULL;
|
EVP_PKEY* pkey = NULL;
|
||||||
const unsigned char* server_key = (const unsigned char*)server_key_der_2048;
|
const unsigned char* server_key = (const unsigned char*)server_key_der_2048;
|
||||||
|
|
||||||
@ -15699,7 +15700,6 @@ static void test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
/* test loading RSA key using BIO */
|
/* test loading RSA key using BIO */
|
||||||
#if !defined(NO_RSA) && !defined(NO_FILESYSTEM)
|
#if !defined(NO_RSA) && !defined(NO_FILESYSTEM)
|
||||||
{
|
{
|
||||||
BIO* bio;
|
|
||||||
XFILE file;
|
XFILE file;
|
||||||
const char* fname = "./certs/server-key.pem";
|
const char* fname = "./certs/server-key.pem";
|
||||||
size_t sz;
|
size_t sz;
|
||||||
@ -15719,14 +15719,15 @@ static void test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
AssertNotNull((pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)));
|
AssertNotNull((pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)));
|
||||||
XFREE(buf, NULL, DYNAMIC_TYPE_FILE);
|
XFREE(buf, NULL, DYNAMIC_TYPE_FILE);
|
||||||
BIO_free(bio);
|
BIO_free(bio);
|
||||||
|
bio = NULL;
|
||||||
EVP_PKEY_free(pkey);
|
EVP_PKEY_free(pkey);
|
||||||
|
pkey = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* test loading ECC key using BIO */
|
/* test loading ECC key using BIO */
|
||||||
#if defined(HAVE_ECC) && !defined(NO_FILESYSTEM)
|
#if defined(HAVE_ECC) && !defined(NO_FILESYSTEM)
|
||||||
{
|
{
|
||||||
BIO* bio;
|
|
||||||
XFILE file;
|
XFILE file;
|
||||||
const char* fname = "./certs/ecc-key.pem";
|
const char* fname = "./certs/ecc-key.pem";
|
||||||
size_t sz;
|
size_t sz;
|
||||||
@ -15746,13 +15747,14 @@ static void test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
AssertNotNull((pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)));
|
AssertNotNull((pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)));
|
||||||
XFREE(buf, NULL, DYNAMIC_TYPE_FILE);
|
XFREE(buf, NULL, DYNAMIC_TYPE_FILE);
|
||||||
BIO_free(bio);
|
BIO_free(bio);
|
||||||
|
bio = NULL;
|
||||||
EVP_PKEY_free(pkey);
|
EVP_PKEY_free(pkey);
|
||||||
|
pkey = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(NO_RSA) && (defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN))
|
#if !defined(NO_RSA) && (defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN))
|
||||||
{
|
{
|
||||||
BIO* bio;
|
|
||||||
EVP_PKEY* pkey2 = NULL;
|
EVP_PKEY* pkey2 = NULL;
|
||||||
unsigned char extra[10];
|
unsigned char extra[10];
|
||||||
int i;
|
int i;
|
||||||
@ -15793,7 +15795,9 @@ static void test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BIO_free(bio);
|
BIO_free(bio);
|
||||||
|
bio = NULL;
|
||||||
EVP_PKEY_free(pkey);
|
EVP_PKEY_free(pkey);
|
||||||
|
pkey = NULL;
|
||||||
EVP_PKEY_free(pkey2);
|
EVP_PKEY_free(pkey2);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -15835,7 +15839,9 @@ static void test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
AssertIntEQ(SSL_CTX_use_PrivateKey(ctx, pkey), SSL_SUCCESS);
|
AssertIntEQ(SSL_CTX_use_PrivateKey(ctx, pkey), SSL_SUCCESS);
|
||||||
|
|
||||||
EVP_PKEY_free(pkey);
|
EVP_PKEY_free(pkey);
|
||||||
|
pkey = NULL;
|
||||||
BIO_free(bio);
|
BIO_free(bio);
|
||||||
|
bio = NULL;
|
||||||
SSL_CTX_free(ctx);
|
SSL_CTX_free(ctx);
|
||||||
}
|
}
|
||||||
#endif /* !defined(NO_DES3) */
|
#endif /* !defined(NO_DES3) */
|
||||||
@ -15865,6 +15871,7 @@ static void test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
AssertIntEQ(SSL_CTX_use_PrivateKey(ctx, pkey), SSL_SUCCESS);
|
AssertIntEQ(SSL_CTX_use_PrivateKey(ctx, pkey), SSL_SUCCESS);
|
||||||
|
|
||||||
EVP_PKEY_free(pkey);
|
EVP_PKEY_free(pkey);
|
||||||
|
pkey = NULL;
|
||||||
SSL_CTX_free(ctx);
|
SSL_CTX_free(ctx);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -15872,6 +15879,9 @@ static void test_wolfSSL_PEM_PrivateKey(void)
|
|||||||
printf(resultFmt, passed);
|
printf(resultFmt, passed);
|
||||||
|
|
||||||
(void)server_key;
|
(void)server_key;
|
||||||
|
(void)bio;
|
||||||
|
(void)pkey;
|
||||||
|
|
||||||
#endif /* OPENSSL_EXTRA && !NO_CERTS && !NO_RSA && USE_CERT_BUFFERS_2048 */
|
#endif /* OPENSSL_EXTRA && !NO_CERTS && !NO_RSA && USE_CERT_BUFFERS_2048 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user