mirror of
https://github.com/adulau/ssldump.git
synced 2024-12-22 16:05:58 +00:00
calculate session hash
This commit is contained in:
parent
5d804ef1a4
commit
b4cd538dfa
1 changed files with 73 additions and 35 deletions
108
ssl/ssldecode.c
108
ssl/ssldecode.c
|
@ -92,6 +92,7 @@ struct ssl_decoder_ {
|
|||
Data *PMS;
|
||||
Data *MS;
|
||||
Data *handshake_messages;
|
||||
Data *session_hash;
|
||||
ssl_rec_decoder *c_to_s;
|
||||
ssl_rec_decoder *s_to_c;
|
||||
ssl_rec_decoder *c_to_s_n;
|
||||
|
@ -112,6 +113,8 @@ static int ssl3_generate_export_iv PROTO_LIST((ssl_obj *ssl,
|
|||
Data *rnd1,Data *rnd2,Data *out));
|
||||
static int ssl_generate_keying_material PROTO_LIST((ssl_obj *ssl,
|
||||
ssl_decoder *d));
|
||||
static int ssl_generate_session_hash PROTO_LIST((ssl_obj *ssl,
|
||||
ssl_decoder *d));
|
||||
#endif
|
||||
|
||||
static int ssl_create_session_lookup_key PROTO_LIST((ssl_obj *ssl,
|
||||
|
@ -216,6 +219,7 @@ int ssl_decoder_destroy(dp)
|
|||
r_data_destroy(&d->PMS);
|
||||
r_data_destroy(&d->MS);
|
||||
r_data_destroy(&d->handshake_messages);
|
||||
r_data_destroy(&d->session_hash);
|
||||
ssl_destroy_rec_decoder(&d->c_to_s);
|
||||
ssl_destroy_rec_decoder(&d->c_to_s_n);
|
||||
ssl_destroy_rec_decoder(&d->s_to_c);
|
||||
|
@ -384,6 +388,35 @@ int ssl_decode_record(ssl,dec,direction,ct,version,d)
|
|||
#endif
|
||||
}
|
||||
|
||||
int ssl_update_handshake_messages(ssl,data)
|
||||
ssl_obj *ssl;
|
||||
Data *data;
|
||||
{
|
||||
Data *hms;
|
||||
UCHAR *d;
|
||||
int l,r,_status;
|
||||
|
||||
hms = ssl->decoder->handshake_messages;
|
||||
d = data->data-4;
|
||||
l = data->len+4;
|
||||
|
||||
if(hms){
|
||||
if(!(hms->data = realloc(hms->data,l+hms->len)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
memcpy(hms->data+hms->len,d,l);
|
||||
hms->len+=l;
|
||||
}
|
||||
else{
|
||||
if(r=r_data_create(&hms,d,l))
|
||||
ABORT(r);
|
||||
ssl->decoder->handshake_messages=hms;
|
||||
}
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
static int ssl_create_session_lookup_key(ssl,id,idlen,keyp,keyl)
|
||||
ssl_obj *ssl;
|
||||
|
@ -567,37 +600,6 @@ int ssl_process_client_key_exchange(ssl,d,msg,len)
|
|||
}
|
||||
|
||||
|
||||
|
||||
int ssl_update_handshake_messages(ssl,data)
|
||||
ssl_obj *ssl;
|
||||
Data *data;
|
||||
{
|
||||
Data *hms;
|
||||
UCHAR *d;
|
||||
int l,r,_status;
|
||||
|
||||
hms = ssl->decoder->handshake_messages;
|
||||
d = data->data-4;
|
||||
l = data->len+4;
|
||||
|
||||
if(hms){
|
||||
if(!(hms->data = realloc(hms->data,l+hms->len)))
|
||||
ABORT(R_NO_MEMORY);
|
||||
|
||||
memcpy(hms->data+hms->len,d,l);
|
||||
hms->len+=l;
|
||||
}
|
||||
else{
|
||||
if(r=r_data_create(&hms,d,l))
|
||||
ABORT(r);
|
||||
ssl->decoder->handshake_messages=hms;
|
||||
}
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
#ifdef OPENSSL
|
||||
static int tls_P_hash(ssl,secret,seed,md,out)
|
||||
ssl_obj *ssl;
|
||||
|
@ -854,10 +856,13 @@ static int ssl_generate_keying_material(ssl,d)
|
|||
if(!d->MS){
|
||||
if(r=r_data_alloc(&d->MS,48))
|
||||
ABORT(r);
|
||||
|
||||
if(r=PRF(ssl,d->PMS,"master secret",d->client_random,d->server_random,
|
||||
d->MS))
|
||||
ABORT(r);
|
||||
|
||||
if (ssl->extensions->extended_master_secret)
|
||||
ssl_generate_session_hash(ssl,d);
|
||||
else
|
||||
if(r=PRF(ssl,d->PMS,"master secret",d->client_random,d->server_random,
|
||||
d->MS))
|
||||
ABORT(r);
|
||||
|
||||
CRDUMPD("MS",d->MS);
|
||||
}
|
||||
|
@ -992,4 +997,37 @@ static int ssl_generate_keying_material(ssl,d)
|
|||
return(_status);
|
||||
}
|
||||
|
||||
static int ssl_generate_session_hash(ssl,d)
|
||||
ssl_obj *ssl;
|
||||
ssl_decoder *d;
|
||||
/* Data **sh; */
|
||||
{
|
||||
UCHAR *out[32];
|
||||
int dgi;
|
||||
unsigned int len;
|
||||
const EVP_MD *md;
|
||||
EVP_MD_CTX dgictx;
|
||||
|
||||
switch(ssl->version){
|
||||
case TLSV12_VERSION:
|
||||
dgi = MAX(DIG_SHA256, ssl->cs->dig)-0x40;
|
||||
if ((md=EVP_get_digestbyname(digests[dgi])) == NULL) {
|
||||
DBG((0,"Cannot get EVP for digest %s, openssl library current?",
|
||||
digests[dgi]));
|
||||
ERETURN(SSL_BAD_MAC);
|
||||
}
|
||||
break;
|
||||
case SSLV3_VERSION:
|
||||
case TLSV1_VERSION:
|
||||
case TLSV11_VERSION:
|
||||
default:
|
||||
exit(1);
|
||||
/* ABORT(SSL_CANT_DO_CIPHER); */
|
||||
}
|
||||
|
||||
EVP_DigestInit(&dgictx, md);
|
||||
EVP_DigestUpdate(&dgictx, d->handshake_messages->data, d->handshake_messages->len);
|
||||
EVP_DigestFinal(&dgictx, out, &len);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue