init cipher specs, check client key exchange state b4 process

This commit is contained in:
toddouska
2012-10-03 11:57:20 -07:00
parent 5f598e2649
commit e970cdfbc0
3 changed files with 37 additions and 0 deletions

View File

@ -105,6 +105,8 @@ enum CyaSSL_ErrorCodes {
SEQUENCE_ERROR = -270, /* dtls sequence error */
SUITES_ERROR = -271, /* suites pointer error */
SSL_NO_PEM_HEADER = -272, /* no PEM header found */
OUT_OF_ORDER_E = -273, /* out of order message */
BAD_KEA_TYPE_E = -274, /* bad KEA type found */
/* add strings to SetErrorString !!!!! */
/* begin negotiation parameter errors */

View File

@ -872,6 +872,8 @@ typedef struct CipherSpecs {
} CipherSpecs;
void InitCipherSpecs(CipherSpecs* cs);
/* Supported Ciphers from page 43 */
enum BulkCipherAlgorithm {

View File

@ -489,6 +489,22 @@ void FreeCiphers(CYASSL* ssl)
}
void InitCipherSpecs(CipherSpecs* cs)
{
cs->bulk_cipher_algorithm = -1;
cs->cipher_type = -1;
cs->mac_algorithm = -1;
cs->kea = -1;
cs->sig_algo = -1;
cs->hash_size = 0;
cs->static_ecdh = 0;
cs->key_size = 0;
cs->iv_size = 0;
cs->block_size = 0;
}
void InitSuites(Suites* suites, ProtocolVersion pv, byte haveDH, byte havePSK,
byte haveNTRU, byte haveECDSAsig, byte haveStaticECC, int side)
{
@ -4317,6 +4333,14 @@ void SetErrorString(int error, char* str)
XSTRNCPY(str, "No PEM Header Error", max);
break;
case OUT_OF_ORDER_E:
XSTRNCPY(str, "Out of order message, fatal", max);
break;
case BAD_KEA_TYPE_E:
XSTRNCPY(str, "Bad KEA type found", max);
break;
default :
XSTRNCPY(str, "unknown error number", max);
}
@ -7301,6 +7325,11 @@ int SetCipherList(Suites* s, const char* list)
word32 length = 0;
byte* out;
if (ssl->options.clientState < CLIENT_HELLO_COMPLETE) {
CYASSL_MSG("Client sending keyexchange at wrong time");
return OUT_OF_ORDER_E;
}
if (ssl->options.verifyPeer && ssl->options.failNoCert)
if (!ssl->options.havePeerCert) {
CYASSL_MSG("client didn't present peer cert");
@ -7471,6 +7500,10 @@ int SetCipherList(Suites* s, const char* list)
ret = MakeMasterSecret(ssl);
#endif /* OPENSSL_EXTRA */
}
else {
CYASSL_MSG("Bad kea type");
return BAD_KEA_TYPE_E;
}
if (ret == 0) {
ssl->options.clientState = CLIENT_KEYEXCHANGE_COMPLETE;