fix ecc key load w/ no rsa, ssn5

This commit is contained in:
toddouska 2013-03-20 09:18:05 -07:00
parent 0f8111fc77
commit f878dbcef2
2 changed files with 15 additions and 7 deletions

View File

@ -1010,14 +1010,14 @@ void InitSuites(Suites* suites, ProtocolVersion pv, byte haveRSA, byte havePSK,
#endif #endif
#ifdef BUILD_TLS_PSK_WITH_NULL_SHA256 #ifdef BUILD_TLS_PSK_WITH_NULL_SHA256
if (tls & havePSK) { if (tls && havePSK) {
suites->suites[idx++] = 0; suites->suites[idx++] = 0;
suites->suites[idx++] = TLS_PSK_WITH_NULL_SHA256; suites->suites[idx++] = TLS_PSK_WITH_NULL_SHA256;
} }
#endif #endif
#ifdef BUILD_TLS_PSK_WITH_NULL_SHA #ifdef BUILD_TLS_PSK_WITH_NULL_SHA
if (tls & havePSK) { if (tls && havePSK) {
suites->suites[idx++] = 0; suites->suites[idx++] = 0;
suites->suites[idx++] = TLS_PSK_WITH_NULL_SHA; suites->suites[idx++] = TLS_PSK_WITH_NULL_SHA;
} }
@ -1135,8 +1135,10 @@ void InitSuites(Suites* suites, ProtocolVersion pv, byte haveRSA, byte havePSK,
suites->hashSigAlgo[idx++] = sha256_mac; suites->hashSigAlgo[idx++] = sha256_mac;
suites->hashSigAlgo[idx++] = ecc_dsa_sa_algo; suites->hashSigAlgo[idx++] = ecc_dsa_sa_algo;
#endif #endif
suites->hashSigAlgo[idx++] = sha_mac; #ifndef NO_SHA
suites->hashSigAlgo[idx++] = ecc_dsa_sa_algo; suites->hashSigAlgo[idx++] = sha_mac;
suites->hashSigAlgo[idx++] = ecc_dsa_sa_algo;
#endif
} }
if (haveRSAsig) { if (haveRSAsig) {
@ -1148,8 +1150,10 @@ void InitSuites(Suites* suites, ProtocolVersion pv, byte haveRSA, byte havePSK,
suites->hashSigAlgo[idx++] = sha256_mac; suites->hashSigAlgo[idx++] = sha256_mac;
suites->hashSigAlgo[idx++] = rsa_sa_algo; suites->hashSigAlgo[idx++] = rsa_sa_algo;
#endif #endif
suites->hashSigAlgo[idx++] = sha_mac; #ifndef NO_SHA
suites->hashSigAlgo[idx++] = rsa_sa_algo; suites->hashSigAlgo[idx++] = sha_mac;
suites->hashSigAlgo[idx++] = rsa_sa_algo;
#endif
} }
suites->hashSigAlgoSz = idx; suites->hashSigAlgoSz = idx;

View File

@ -1178,6 +1178,7 @@ int CyaSSL_Init(void)
int ret; int ret;
int dynamicType = 0; int dynamicType = 0;
int eccKey = 0; int eccKey = 0;
int rsaKey = 0;
void* heap = ctx ? ctx->heap : NULL; void* heap = ctx ? ctx->heap : NULL;
info.set = 0; info.set = 0;
@ -1416,12 +1417,14 @@ int CyaSSL_Init(void)
FreeRsaKey(&key); FreeRsaKey(&key);
return SSL_BAD_FILE; return SSL_BAD_FILE;
} }
} else {
rsaKey = 1;
} }
FreeRsaKey(&key); FreeRsaKey(&key);
} }
#endif #endif
#ifdef HAVE_ECC #ifdef HAVE_ECC
if (eccKey ) { if (!rsaKey) {
/* make sure ECC key can be used */ /* make sure ECC key can be used */
word32 idx = 0; word32 idx = 0;
ecc_key key; ecc_key key;
@ -1432,6 +1435,7 @@ int CyaSSL_Init(void)
return SSL_BAD_FILE; return SSL_BAD_FILE;
} }
ecc_free(&key); ecc_free(&key);
eccKey = 1;
ctx->haveStaticECC = 1; ctx->haveStaticECC = 1;
if (ssl) if (ssl)
ssl->options.haveStaticECC = 1; ssl->options.haveStaticECC = 1;