check on key type with SetRsaExternal and fix for function name after rebase

This commit is contained in:
Jacob Barthelmeh
2017-08-10 12:06:43 -06:00
parent d1b24f2bb1
commit a60db81d09
2 changed files with 32 additions and 40 deletions

View File

@@ -20408,17 +20408,6 @@ static void InitwolfSSL_Rsa(WOLFSSL_RSA* rsa)
{ {
if (rsa) { if (rsa) {
XMEMSET(rsa, 0, sizeof(WOLFSSL_RSA)); XMEMSET(rsa, 0, sizeof(WOLFSSL_RSA));
rsa->n = NULL;
rsa->e = NULL;
rsa->d = NULL;
rsa->p = NULL;
rsa->q = NULL;
rsa->dmp1 = NULL;
rsa->dmq1 = NULL;
rsa->iqmp = NULL;
rsa->internal = NULL;
rsa->inSet = 0;
rsa->exSet = 0;
} }
} }
@@ -20789,6 +20778,7 @@ static int SetRsaExternal(WOLFSSL_RSA* rsa)
return WOLFSSL_FATAL_ERROR; return WOLFSSL_FATAL_ERROR;
} }
if (key->type == RSA_PRIVATE) {
if (SetIndividualExternal(&rsa->d, &key->d) != WOLFSSL_SUCCESS) { if (SetIndividualExternal(&rsa->d, &key->d) != WOLFSSL_SUCCESS) {
WOLFSSL_MSG("rsa d key error"); WOLFSSL_MSG("rsa d key error");
return WOLFSSL_FATAL_ERROR; return WOLFSSL_FATAL_ERROR;
@@ -20818,7 +20808,7 @@ static int SetRsaExternal(WOLFSSL_RSA* rsa)
WOLFSSL_MSG("rsa u key error"); WOLFSSL_MSG("rsa u key error");
return WOLFSSL_FATAL_ERROR; return WOLFSSL_FATAL_ERROR;
} }
}
rsa->exSet = 1; rsa->exSet = 1;
return WOLFSSL_SUCCESS; return WOLFSSL_SUCCESS;
@@ -24348,10 +24338,12 @@ int wolfSSL_RSA_LoadDer_ex(WOLFSSL_RSA* rsa, const unsigned char* derBuf,
return WOLFSSL_FATAL_ERROR; return WOLFSSL_FATAL_ERROR;
} }
if(opt == WOLFSSL_RSA_LOAD_PRIVATE) if (opt == WOLFSSL_RSA_LOAD_PRIVATE) {
ret = wc_RsaPrivateKeyDecode(derBuf, &idx, (RsaKey*)rsa->internal, derSz); ret = wc_RsaPrivateKeyDecode(derBuf, &idx, (RsaKey*)rsa->internal, derSz);
else }
else {
ret = wc_RsaPublicKeyDecode(derBuf, &idx, (RsaKey*)rsa->internal, derSz); ret = wc_RsaPublicKeyDecode(derBuf, &idx, (RsaKey*)rsa->internal, derSz);
}
if (ret < 0) { if (ret < 0) {
if (opt == WOLFSSL_RSA_LOAD_PRIVATE) { if (opt == WOLFSSL_RSA_LOAD_PRIVATE) {

View File

@@ -689,7 +689,7 @@ int wc_d2i_PKCS12(const byte* der, word32 derSz, WC_PKCS12* pkcs12)
/* helper function to free WC_DerCertList */ /* helper function to free WC_DerCertList */
static void freeCertList(WC_DerCertList* list, void* heap) void wc_FreeCertList(WC_DerCertList* list, void* heap)
{ {
WC_DerCertList* current = list; WC_DerCertList* current = list;
WC_DerCertList* next; WC_DerCertList* next;
@@ -1137,7 +1137,7 @@ exit_pk12par:
buf = NULL; buf = NULL;
} }
freeCertList(certList, pkcs12->heap); wc_FreeCertList(certList, pkcs12->heap);
} }
return ret; return ret;