|
@@ -272,14 +272,17 @@ int update_flow(flow *f) {
|
|
|
break;
|
|
|
case CCS:
|
|
|
printf("CCS (%x:%d -> %x:%d) \n", f->src_ip.s_addr, f->src_port, f->dst_ip.s_addr, f->dst_port);
|
|
|
+ /*Initialize ciphers */
|
|
|
+ if ((!f->in_encrypted) && (!f->out_encrypted)){
|
|
|
+ init_ciphers(f);
|
|
|
+ }
|
|
|
+
|
|
|
if(incoming){
|
|
|
f->in_encrypted = 1;
|
|
|
} else {
|
|
|
f->out_encrypted = 1;
|
|
|
}
|
|
|
|
|
|
- /*Initialize ciphers */
|
|
|
- init_ciphers(f);
|
|
|
break;
|
|
|
case ALERT:
|
|
|
p = record;
|
|
@@ -367,10 +370,14 @@ int remove_flow(flow *f) {
|
|
|
EVP_MD_CTX_destroy(f->finish_md_ctx);
|
|
|
//Clean up cipher ctxs
|
|
|
if(f->clnt_read_ctx != NULL){
|
|
|
- EVP_CIPHER_CTX_free(f->clnt_read_ctx);
|
|
|
+ EVP_CIPHER_CTX_cleanup(f->clnt_read_ctx);
|
|
|
+ OPENSSL_free(f->clnt_read_ctx);
|
|
|
+ f->clnt_read_ctx = NULL;
|
|
|
}
|
|
|
if(f->clnt_write_ctx != NULL){
|
|
|
- EVP_CIPHER_CTX_free(f->clnt_write_ctx);
|
|
|
+ EVP_CIPHER_CTX_cleanup(f->clnt_write_ctx);
|
|
|
+ OPENSSL_free(f->clnt_write_ctx);
|
|
|
+ f->clnt_write_ctx = NULL;
|
|
|
}
|
|
|
if(f->srvr_read_ctx != NULL){
|
|
|
EVP_CIPHER_CTX_free(f->srvr_read_ctx);
|
|
@@ -383,6 +390,13 @@ int remove_flow(flow *f) {
|
|
|
EC_KEY_free(f->ecdh);
|
|
|
}
|
|
|
|
|
|
+ if(f->resume_session == 1){
|
|
|
+ if(f->current_session->session_ticket != NULL){
|
|
|
+ free(f->current_session->session_ticket);
|
|
|
+ }
|
|
|
+ free(f->current_session);
|
|
|
+ }
|
|
|
+
|
|
|
sem_wait(&flow_table_lock);
|
|
|
flow_entry *entry = table->first_entry;
|
|
|
if(entry->f == f){
|
|
@@ -559,8 +573,6 @@ int verify_session_id(flow *f, uint8_t *hs){
|
|
|
save_session_id(f, p);
|
|
|
}
|
|
|
|
|
|
- //now check
|
|
|
-
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
@@ -632,7 +644,6 @@ int check_session(flow *f, uint8_t *hs, uint32_t len){
|
|
|
new_session->session_ticket = calloc(1, ext_len);
|
|
|
memcpy(new_session->session_ticket, p, ext_len);
|
|
|
f->current_session = new_session;
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
p += ext_len;
|
|
@@ -678,6 +689,10 @@ int save_session_id(flow *f, uint8_t *hs){
|
|
|
memcpy(new_session->session_id, p, new_session->session_id_len);
|
|
|
new_session->next = NULL;
|
|
|
|
|
|
+ if(f->current_session != NULL){
|
|
|
+ free(f->current_session);
|
|
|
+ }
|
|
|
+ f->resume_session = 0;
|
|
|
f->current_session = new_session;
|
|
|
|
|
|
if(sessions->first_session == NULL){
|