remove pubKeyX509 from WOLFSSL_X509 structure

This commit is contained in:
Jacob Barthelmeh
2019-04-19 15:15:02 -06:00
parent 29101a29c9
commit 82796d4b4c
2 changed files with 43 additions and 45 deletions

View File

@@ -15375,12 +15375,6 @@ WOLFSSL_X509* wolfSSL_X509_d2i(WOLFSSL_X509** x509, const byte* in, int len)
int wolfSSL_X509_get_pubkey_buffer(WOLFSSL_X509* x509, int wolfSSL_X509_get_pubkey_buffer(WOLFSSL_X509* x509,
unsigned char* buf, int* bufSz) unsigned char* buf, int* bufSz)
{ {
WOLFSSL_ENTER("wolfSSL_X509_get_pubkey_buffer");
if (x509 == NULL || bufSz == NULL)
return WOLFSSL_FATAL_ERROR;
/* get pointer into DER for X.509 public key */
if (x509->pubKeyX509 == NULL) {
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
DecodedCert* cert; DecodedCert* cert;
#else #else
@@ -15391,12 +15385,23 @@ WOLFSSL_X509* wolfSSL_X509_d2i(WOLFSSL_X509** x509, const byte* in, int len)
int length = 0; int length = 0;
int ret, derSz = 0; int ret, derSz = 0;
int badDate = 0; int badDate = 0;
const byte* pubKeyX509;
int pubKeyX509Sz;
WOLFSSL_ENTER("wolfSSL_X509_get_pubkey_buffer");
if (x509 == NULL || bufSz == NULL) {
WOLFSSL_LEAVE("wolfSSL_X509_get_pubkey_buffer", BAD_FUNC_ARG);
return WOLFSSL_FATAL_ERROR;
}
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert),
x509->heap, DYNAMIC_TYPE_TMP_BUFFER); x509->heap, DYNAMIC_TYPE_TMP_BUFFER);
if (decoded == NULL) if (cert == NULL) {
return MEMORY_E; WOLFSSL_LEAVE("wolfSSL_X509_get_pubkey_buffer", MEMORY_E);
return WOLFSSL_FATAL_ERROR;
}
#endif #endif
der = wolfSSL_X509_get_der(x509, &derSz); der = wolfSSL_X509_get_der(x509, &derSz);
@@ -15404,10 +15409,10 @@ WOLFSSL_X509* wolfSSL_X509_d2i(WOLFSSL_X509** x509, const byte* in, int len)
ret = wc_GetPubX509(cert, 0, &badDate); ret = wc_GetPubX509(cert, 0, &badDate);
if (ret >= 0) { if (ret >= 0) {
idx = cert->srcIdx; idx = cert->srcIdx;
x509->pubKeyX509 = cert->source + cert->srcIdx; pubKeyX509 = cert->source + cert->srcIdx;
ret = GetSequence(cert->source, &cert->srcIdx, &length, ret = GetSequence(cert->source, &cert->srcIdx, &length,
cert->maxIdx); cert->maxIdx);
x509->pubKeyX509Sz = length + (cert->srcIdx - idx); pubKeyX509Sz = length + (cert->srcIdx - idx);
} }
FreeDecodedCert(cert); FreeDecodedCert(cert);
@@ -15416,15 +15421,13 @@ WOLFSSL_X509* wolfSSL_X509_d2i(WOLFSSL_X509** x509, const byte* in, int len)
#endif #endif
if (ret < 0) { if (ret < 0) {
x509->pubKeyX509 = NULL; WOLFSSL_LEAVE("wolfSSL_X509_get_pubkey_buffer", ret);
x509->pubKeyX509Sz = 0; return WOLFSSL_FATAL_ERROR;
return ret;
}
} }
if (buf != NULL) if (buf != NULL)
XMEMCPY(buf, x509->pubKeyX509, x509->pubKeyX509Sz); XMEMCPY(buf, pubKeyX509, pubKeyX509Sz);
*bufSz = x509->pubKeyX509Sz; *bufSz = pubKeyX509Sz;
return WOLFSSL_SUCCESS; return WOLFSSL_SUCCESS;
} }

View File

@@ -3417,11 +3417,6 @@ struct WOLFSSL_X509 {
DNS_entry* altNames; /* alt names list */ DNS_entry* altNames; /* alt names list */
buffer pubKey; buffer pubKey;
int pubKeyOID; int pubKeyOID;
#ifdef OPENSSL_EXTRA
const byte* pubKeyX509; /* pointer to internal X509 for where X.509
* format key starts */
int pubKeyX509Sz;
#endif
DNS_entry* altNamesNext; /* hint for retrieval */ DNS_entry* altNamesNext; /* hint for retrieval */
#if defined(HAVE_ECC) || defined(HAVE_ED25519) #if defined(HAVE_ECC) || defined(HAVE_ED25519)
word32 pkCurveOID; word32 pkCurveOID;