Merge pull request #3571 from JacobBarthelmeh/Testing

Some initial testing and clean up
This commit is contained in:
toddouska
2020-12-18 14:05:26 -08:00
committed by GitHub
10 changed files with 69 additions and 30 deletions

View File

@@ -987,6 +987,9 @@ int wolfSSL_i2d_OCSP_CERTID(WOLFSSL_OCSP_CERTID* id, unsigned char** data)
}
else {
*data = (unsigned char*)XMALLOC(id->rawCertIdSize, NULL, DYNAMIC_TYPE_OPENSSL);
if (*data == NULL) {
return WOLFSSL_FAILURE;
}
XMEMCPY(*data, id->rawCertId, id->rawCertIdSize);
}

View File

@@ -6333,7 +6333,7 @@ int wolfSSL_CertManagerDisableOCSPStapling(WOLFSSL_CERT_MANAGER* cm)
/* require OCSP stapling response */
int wolfSSL_CertManagerEnableOCSPMustStaple(WOLFSSL_CERT_MANAGER* cm)
{
int ret = WOLFSSL_SUCCESS;
int ret;
WOLFSSL_ENTER("wolfSSL_CertManagerEnableOCSPMustStaple");
@@ -6345,6 +6345,7 @@ int wolfSSL_CertManagerEnableOCSPMustStaple(WOLFSSL_CERT_MANAGER* cm)
#ifndef NO_WOLFSSL_CLIENT
cm->ocspMustStaple = 1;
#endif
ret = WOLFSSL_SUCCESS;
#else
ret = NOT_COMPILED_IN;
#endif
@@ -6354,7 +6355,7 @@ int wolfSSL_CertManagerEnableOCSPMustStaple(WOLFSSL_CERT_MANAGER* cm)
int wolfSSL_CertManagerDisableOCSPMustStaple(WOLFSSL_CERT_MANAGER* cm)
{
int ret = WOLFSSL_SUCCESS;
int ret;
WOLFSSL_ENTER("wolfSSL_CertManagerDisableOCSPMustStaple");
@@ -6366,6 +6367,7 @@ int wolfSSL_CertManagerDisableOCSPMustStaple(WOLFSSL_CERT_MANAGER* cm)
#ifndef NO_WOLFSSL_CLIENT
cm->ocspMustStaple = 0;
#endif
ret = WOLFSSL_SUCCESS;
#else
ret = NOT_COMPILED_IN;
#endif
@@ -7408,14 +7410,14 @@ int wolfSSL_CTX_check_private_key(const WOLFSSL_CTX* ctx)
ctx->privateKeyId, ctx->heap,
ctx->privateKeyDevId);
if (ret == 0 && der->keyOID == RSAk) {
ret = wc_CryptoCb_RsaCheckPrivKey(pkey, der->publicKey,
ret = wc_CryptoCb_RsaCheckPrivKey((RsaKey*)pkey, der->publicKey,
der->pubKeySize);
wc_FreeRsaKey(pkey);
wc_FreeRsaKey((RsaKey*)pkey);
}
else if (ret == 0 && der->keyOID == ECDSAk) {
ret = wc_CryptoCb_EccCheckPrivKey(pkey, der->publicKey,
ret = wc_CryptoCb_EccCheckPrivKey((ecc_key*)pkey, der->publicKey,
der->pubKeySize);
wc_ecc_free(pkey);
wc_ecc_free((ecc_key*)pkey);
}
if (pkey != NULL) {
XFREE(pkey, ctx->heap, type);
@@ -8015,18 +8017,18 @@ int wolfSSL_check_private_key(const WOLFSSL* ssl)
ssl->buffers.keyId, ssl->heap,
ssl->buffers.keyDevId);
if (ret == 0 && der.keyOID == RSAk) {
ret = wc_CryptoCb_RsaCheckPrivKey(pkey, der.publicKey,
ret = wc_CryptoCb_RsaCheckPrivKey((RsaKey*)pkey, der.publicKey,
der.pubKeySize);
if (ret == 0)
ret = 1;
wc_FreeRsaKey(pkey);
wc_FreeRsaKey((RsaKey*)pkey);
}
else if (ret == 0 && der.keyOID == ECDSAk) {
ret = wc_CryptoCb_EccCheckPrivKey(pkey, der.publicKey,
ret = wc_CryptoCb_EccCheckPrivKey((ecc_key*)pkey, der.publicKey,
der.pubKeySize);
if (ret == 0)
ret = 1;
wc_ecc_free(pkey);
wc_ecc_free((ecc_key*)pkey);
}
if (pkey != NULL) {
XFREE(pkey, ssl->heap, type);
@@ -15058,11 +15060,13 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
/* Need a persistent copy of the subject name. */
node->data.name = wolfSSL_X509_NAME_dup(subjectName);
/*
* Original cert will be freed so make sure not to try to access
* it in the future.
*/
node->data.name->x509 = NULL;
if (node->data.name != NULL) {
/*
* Original cert will be freed so make sure not to try to access
* it in the future.
*/
node->data.name->x509 = NULL;
}
/* Put node on the front of the list. */
node->num = (list == NULL) ? 1 : list->num + 1;
@@ -34101,6 +34105,11 @@ int wolfSSL_PEM_write_bio_RSAPrivateKey(WOLFSSL_BIO* bio, WOLFSSL_RSA* key,
return WOLFSSL_FAILURE;
}
if (derBuf == NULL) {
WOLFSSL_MSG("wolfSSL_RSA_To_Der failed to get buffer");
return WOLFSSL_FAILURE;
}
pkey->pkey.ptr = (char*)XMALLOC(derSz, bio->heap,
DYNAMIC_TYPE_TMP_BUFFER);
if (pkey->pkey.ptr == NULL) {
@@ -34156,6 +34165,11 @@ int wolfSSL_PEM_write_bio_RSA_PUBKEY(WOLFSSL_BIO* bio, WOLFSSL_RSA* rsa)
return WOLFSSL_FAILURE;
}
if (derBuf == NULL) {
WOLFSSL_MSG("wolfSSL_RSA_To_Der failed to get buffer");
return WOLFSSL_FAILURE;
}
pkey->pkey.ptr = (char*)XMALLOC(derSz, bio->heap,
DYNAMIC_TYPE_TMP_BUFFER);
if (pkey->pkey.ptr == NULL) {
@@ -39615,7 +39629,7 @@ void* wolfSSL_GetDhAgreeCtx(WOLFSSL* ssl)
static int CopyX509NameToCert(WOLFSSL_X509_NAME* n, byte* out)
{
unsigned char* der = NULL;
int length = BAD_FUNC_ARG, ret = BAD_FUNC_ARG;
int length = BAD_FUNC_ARG, ret;
word32 idx = 0;
ret = wolfSSL_i2d_X509_NAME(n, &der);
@@ -41458,9 +41472,11 @@ err:
XMEMCPY(fullName + *idx, "=", 1); *idx = *idx + 1;
data = wolfSSL_ASN1_STRING_data(e->value);
sz = (int)XSTRLEN((const char*)data);
XMEMCPY(fullName + *idx, data, sz);
*idx += sz;
if (data != NULL) {
sz = (int)XSTRLEN((const char*)data);
XMEMCPY(fullName + *idx, data, sz);
*idx += sz;
}
ret++;
}

View File

@@ -4076,6 +4076,11 @@ int TLSX_SupportedCurve_CheckPriority(WOLFSSL* ssl)
return ret;
ext = TLSX_Find(priority, TLSX_SUPPORTED_GROUPS);
if (ext == NULL) {
WOLFSSL_MSG("Could not find supported groups extension");
return 0;
}
curve = (SupportedCurve*)ext->data;
name = curve->name;