Merge pull request #2909 from SKlimaRA/SKlimaRA/crl-and-pkcb

ParseCrl fix, GetPrivateKeySigSize moved from client only section and Coverity fixes.
This commit is contained in:
JacobBarthelmeh
2020-06-19 10:51:50 -06:00
committed by GitHub
3 changed files with 72 additions and 44 deletions

View File

@ -11674,7 +11674,15 @@ exit_ppc:
}
#endif /* WOLFSSL_ASYNC_CRYPT || WOLFSSL_NONBLOCK_OCSP */
#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_NONBLOCK_OCSP) || \
defined(WOLFSSL_SMALL_STACK)
if (args)
{
FreeProcPeerCertArgs(ssl, args);
}
#else
FreeProcPeerCertArgs(ssl, args);
#endif /* WOLFSSL_ASYNC_CRYPT || WOLFSSL_NONBLOCK_OCSP || WOLFSSL_SMALL_STACK */
#if defined(WOLFSSL_ASYNC_CRYPT)
#elif defined(WOLFSSL_NONBLOCK_OCSP)
@ -23854,49 +23862,6 @@ exit_scke:
#ifndef NO_CERTS
#ifdef HAVE_PK_CALLBACKS
int GetPrivateKeySigSize(WOLFSSL* ssl)
{
int sigSz = 0;
if (ssl == NULL)
return 0;
switch (ssl->buffers.keyType) {
#ifndef NO_RSA
#ifdef WC_RSA_PSS
case rsa_pss_sa_algo:
#endif
case rsa_sa_algo:
sigSz = ssl->buffers.keySz;
ssl->hsType = DYNAMIC_TYPE_RSA;
break;
#endif
#ifdef HAVE_ECC
case ecc_dsa_sa_algo:
sigSz = wc_ecc_sig_size_calc(ssl->buffers.keySz);
ssl->hsType = DYNAMIC_TYPE_ECC;
break;
#endif
#ifdef HAVE_ED25519
case ed25519_sa_algo:
sigSz = ED25519_SIG_SIZE; /* fixed known value */
ssl->hsType = DYNAMIC_TYPE_ED25519;
break;
#endif
#ifdef HAVE_ED448
case ed448_sa_algo:
sigSz = ED448_SIG_SIZE; /* fixed known value */
ssl->hsType = DYNAMIC_TYPE_ED448;
break;
#endif
default:
break;
}
return sigSz;
}
#endif /* HAVE_PK_CALLBACKS */
#ifndef WOLFSSL_NO_TLS12
#ifndef WOLFSSL_NO_CLIENT_AUTH
@ -24506,6 +24471,53 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
#endif /* NO_WOLFSSL_CLIENT */
#ifndef NO_CERTS
#ifdef HAVE_PK_CALLBACKS
int GetPrivateKeySigSize(WOLFSSL* ssl)
{
int sigSz = 0;
if (ssl == NULL)
return 0;
switch (ssl->buffers.keyType) {
#ifndef NO_RSA
#ifdef WC_RSA_PSS
case rsa_pss_sa_algo:
#endif
case rsa_sa_algo:
sigSz = ssl->buffers.keySz;
ssl->hsType = DYNAMIC_TYPE_RSA;
break;
#endif
#ifdef HAVE_ECC
case ecc_dsa_sa_algo:
sigSz = wc_ecc_sig_size_calc(ssl->buffers.keySz);
ssl->hsType = DYNAMIC_TYPE_ECC;
break;
#endif
#ifdef HAVE_ED25519
case ed25519_sa_algo:
sigSz = ED25519_SIG_SIZE; /* fixed known value */
ssl->hsType = DYNAMIC_TYPE_ED25519;
break;
#endif
#ifdef HAVE_ED448
case ed448_sa_algo:
sigSz = ED448_SIG_SIZE; /* fixed known value */
ssl->hsType = DYNAMIC_TYPE_ED448;
break;
#endif
default:
break;
}
return sigSz;
}
#endif /* HAVE_PK_CALLBACKS */
#endif /* NO_CERTS */
#ifdef HAVE_ECC
/* returns the WOLFSSL_* version of the curve from the OID sum */
word16 GetCurveByOID(int oidSum) {

View File

@ -25529,6 +25529,7 @@ WOLFSSL_API int wolfSSL_X509_STORE_load_locations(WOLFSSL_X509_STORE *str,
DYNAMIC_TYPE_TMP_BUFFER);
if (readCtx == NULL) {
WOLFSSL_MSG("Memory error");
wolfSSL_CTX_free(ctx);
return WOLFSSL_FAILURE;
}
#endif

View File

@ -3409,6 +3409,10 @@ int UnTraditionalEnc(byte* key, word32 keySz, byte* out, word32* outSz,
/* place iteration count in buffer */
ret = SetShortInt(out, &inOutIdx, itt, *outSz);
if (ret < 0) {
#ifdef WOLFSSL_SMALL_STACK
if (saltTmp != NULL)
XFREE(saltTmp, heap, DYNAMIC_TYPE_TMP_BUFFER);
#endif
return ret;
}
sz += (word32)ret;
@ -3432,6 +3436,10 @@ int UnTraditionalEnc(byte* key, word32 keySz, byte* out, word32* outSz,
/* check key type and get OID if ECC */
if ((ret = wc_GetKeyOID(key, keySz, &curveOID, &oidSz, &algoID, heap))< 0) {
WOLFSSL_MSG("Error getting key OID");
#ifdef WOLFSSL_SMALL_STACK
if (saltTmp != NULL)
XFREE(saltTmp, heap, DYNAMIC_TYPE_TMP_BUFFER);
#endif
return ret;
}
@ -3458,6 +3466,10 @@ int UnTraditionalEnc(byte* key, word32 keySz, byte* out, word32* outSz,
/* plus 3 for tags */
*outSz = tmpSz + MAX_ALGO_SZ + MAX_LENGTH_SZ +MAX_LENGTH_SZ + MAX_SEQ_SZ
+ MAX_LENGTH_SZ + MAX_SEQ_SZ + 3;
#ifdef WOLFSSL_SMALL_STACK
if (saltTmp != NULL)
XFREE(saltTmp, heap, DYNAMIC_TYPE_TMP_BUFFER);
#endif
return LENGTH_ONLY_E;
}
@ -3491,7 +3503,7 @@ int UnTraditionalEnc(byte* key, word32 keySz, byte* out, word32* outSz,
if (cbcIv == NULL) {
if (saltTmp != NULL)
XFREE(saltTmp, heap, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(salt, heap, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(tmp, heap, DYNAMIC_TYPE_TMP_BUFFER);
return MEMORY_E;
}
#endif
@ -13593,6 +13605,8 @@ static int EncodeCertReq(Cert* cert, DerCert* der, RsaKey* rsaKey,
#ifdef HAVE_ECC
if (cert->keyType == ECC_KEY) {
if (eccKey == NULL)
return PUBLIC_KEY_E;
der->publicKeySz = SetEccPublicKey(der->publicKey, eccKey, 1);
}
#endif
@ -15185,6 +15199,7 @@ int DecodeECC_DSA_Sig(const byte* sig, word32 sigLen, mp_int* r, mp_int* s)
}
if (GetInt(s, sig, &idx, sigLen) < 0) {
mp_clear(r);
return ASN_ECC_KEY_E;
}