Skip to content

Commit

Permalink
Merge pull request #2163 from ejohnstown/config-fixes
Browse files Browse the repository at this point in the history
Configuration Fixes
  • Loading branch information
dgarske committed Mar 14, 2019
2 parents b1ea7c0 + 3e3f746 commit 6ff2039
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 33 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ then
AM_CFLAGS="$AM_CFLAGS -DHAVE_AES_DECRYPT -DHAVE_AES_ECB -DWOLFSSL_ALT_NAMES -DWOLFSSL_DER_LOAD -DKEEP_OUR_CERT -DKEEP_PEER_CERT -DHAVE_CRL_IO -DHAVE_IO_TIMEOUT"

# Enable DH const table speedups (eliminates `-lm` math lib dependency)
AM_CFLAGS="$AM_CFLAGS -DHAVE_FFDHE_2048 -DHAVE_FFDHE_3072 -DFP_MAX_BITS=6144"
AM_CFLAGS="$AM_CFLAGS -DHAVE_FFDHE_2048 -DHAVE_FFDHE_3072 -DFP_MAX_BITS=8192"
fi
AM_CONDITIONAL([BUILD_ALL], [test "x$ENABLED_ALL" = "xyes"])

Expand Down
3 changes: 3 additions & 0 deletions examples/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,8 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
wolfSSL_CTX_EnableOCSP(ctx, WOLFSSL_OCSP_NO_NONCE);
}
#endif
#ifndef NO_RSA
/* All the OSCP Stapling test certs are RSA. */
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST) \
|| defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2)
if (wolfSSL_CTX_EnableOCSPStapling(ctx) != WOLFSSL_SUCCESS)
Expand All @@ -1900,6 +1902,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
if (SSL_CTX_load_verify_locations(ctx, "certs/ocsp/intermediate3-ca-cert.pem", 0) != WOLFSSL_SUCCESS)
err_sys_ex(runWithErrors, "can't load ca file, Please run from wolfSSL home dir");
#endif
#endif

#ifdef HAVE_PK_CALLBACKS
if (pkCallbacks)
Expand Down
5 changes: 5 additions & 0 deletions scripts/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ dist_noinst_SCRIPTS+= scripts/resume.test
EXTRA_DIST+= scripts/benchmark.test
EXTRA_DIST+= scripts/memtest.sh

# The CRL and OCSP tests use RSA certificates.
if BUILD_RSA

if BUILD_CRL
# make revoked test rely on completion of resume test
dist_noinst_SCRIPTS+= scripts/crl-revoked.test
Expand Down Expand Up @@ -46,6 +49,8 @@ endif

endif

endif

if BUILD_PSK
dist_noinst_SCRIPTS+= scripts/psk.test
endif
Expand Down
40 changes: 33 additions & 7 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -26559,6 +26559,8 @@ static int EncryptDerKey(byte *der, int *derSz, const EVP_CIPHER* cipher,
#endif /* WOLFSSL_KEY_GEN || WOLFSSL_PEM_TO_DER */

#if defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN)

#ifndef NO_RSA
/* Takes a WOLFSSL_RSA key and writes it out to a WOLFSSL_BIO
*
* bio the WOLFSSL_BIO to write to
Expand Down Expand Up @@ -26639,6 +26641,8 @@ int wolfSSL_PEM_write_bio_RSAPrivateKey(WOLFSSL_BIO* bio, WOLFSSL_RSA* key,
return ret;
}

#endif /* NO_RSA */


int wolfSSL_PEM_write_bio_PrivateKey(WOLFSSL_BIO* bio, WOLFSSL_EVP_PKEY* key,
const WOLFSSL_EVP_CIPHER* cipher,
Expand Down Expand Up @@ -26666,9 +26670,11 @@ int wolfSSL_PEM_write_bio_PrivateKey(WOLFSSL_BIO* bio, WOLFSSL_EVP_PKEY* key,
keyDer = (byte*)key->pkey.ptr;

switch (key->type) {
#ifndef NO_RSA
case EVP_PKEY_RSA:
type = PRIVATEKEY_TYPE;
break;
#endif

#ifndef NO_DSA
case EVP_PKEY_DSA:
Expand Down Expand Up @@ -29920,8 +29926,7 @@ void* wolfSSL_GetDhAgreeCtx(WOLFSSL* ssl)
}


#if defined(WOLFSSL_CERT_GEN) && !defined(NO_RSA)
/* needed SetName function from asn.c is wrapped by NO_RSA */
#if defined(WOLFSSL_CERT_GEN)
/* helper function for CopyX509NameToCertName()
*
* returns WOLFSSL_SUCCESS on success
Expand Down Expand Up @@ -35598,6 +35603,8 @@ int wolfSSL_X509_get_signature_nid(const WOLFSSL_X509 *x)
#endif /* OPENSSL_EXTRA */

#if defined(OPENSSL_ALL)

#ifndef NO_RSA
int wolfSSL_EVP_PKEY_assign_RSA(EVP_PKEY* pkey, WOLFSSL_RSA* key)
{
if (pkey == NULL || key == NULL)
Expand All @@ -35609,6 +35616,7 @@ int wolfSSL_EVP_PKEY_assign_RSA(EVP_PKEY* pkey, WOLFSSL_RSA* key)

return WOLFSSL_SUCCESS;
}
#endif

int wolfSSL_EVP_PKEY_assign_EC_KEY(EVP_PKEY* pkey, WOLFSSL_EC_KEY* key)
{
Expand Down Expand Up @@ -36189,12 +36197,16 @@ int wolfSSL_X509_REQ_sign(WOLFSSL_X509 *req, WOLFSSL_EVP_PKEY *pkey,
Cert cert;
byte der[2048];
int derSz = sizeof(der);
void* key;
int type;
void* key = NULL;
int type = -1;
int sigType;
int hashType;
#ifndef NO_RSA
RsaKey rsa;
#endif
#ifdef HAVE_ECC
ecc_key ecc;
#endif
WC_RNG rng;
word32 idx = 0;

Expand Down Expand Up @@ -36257,6 +36269,7 @@ int wolfSSL_X509_REQ_sign(WOLFSSL_X509 *req, WOLFSSL_EVP_PKEY *pkey,
return WOLFSSL_FAILURE;

/* Create a public key object from requests public key. */
#ifndef NO_RSA
if (req->pubKeyOID == RSAk) {
type = RSA_TYPE;
ret = wc_InitRsaKey(&rsa, req->heap);
Expand All @@ -36270,7 +36283,9 @@ int wolfSSL_X509_REQ_sign(WOLFSSL_X509 *req, WOLFSSL_EVP_PKEY *pkey,
}
key = (void*)&rsa;
}
else {
#endif
#ifdef HAVE_ECC
if (req->pubKeyOID == ECDSAk) {
type = ECC_TYPE;
ret = wc_ecc_init(&ecc);
if (ret != 0)
Expand All @@ -36283,28 +36298,39 @@ int wolfSSL_X509_REQ_sign(WOLFSSL_X509 *req, WOLFSSL_EVP_PKEY *pkey,
}
key = (void*)&ecc;
}
#endif
if (key == NULL)
return WOLFSSL_FAILURE;

/* Make the body of the certificate request. */
ret = wc_MakeCertReq_ex(&cert, der, derSz, type, key);
if (ret < 0)
return WOLFSSL_FAILURE;

/* Dispose of the public key object. */
#ifndef NO_RSA
if (req->pubKeyOID == RSAk)
wc_FreeRsaKey(&rsa);
else
#endif
#ifdef HAVE_ECC
if (req->pubKeyOID == ECDSAk)
wc_ecc_free(&ecc);
#endif

idx = 0;
/* Get the private key object and type from pkey. */
#ifndef NO_RSA
if (pkey->type == EVP_PKEY_RSA) {
type = RSA_TYPE;
key = pkey->rsa->internal;
}
else {
#endif
#ifdef HAVE_ECC
if (pkey->type == EVP_PKEY_EC) {
type = ECC_TYPE;
key = pkey->ecc->internal;
}
#endif

/* Sign the certificate request body. */
ret = wc_InitRng(&rng);
Expand Down
Loading

0 comments on commit 6ff2039

Please sign in to comment.