Skip to content

Commit

Permalink
tls: fix wrong pre_master_key length
Browse files Browse the repository at this point in the history
  • Loading branch information
azzbcc authored and Kaian committed Sep 22, 2021
1 parent c3b4694 commit 1b18bde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 3 additions & 4 deletions src/packet/packet_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,11 @@ static gboolean
packet_tls_process_record_key_exchange(SSLConnection *conn, GBytes *data)
{
// Decrypt PreMasterKey
struct ClientKeyExchange clientkeyex;
memcpy(&clientkeyex, g_bytes_get_data(data, NULL), sizeof(struct ClientKeyExchange));
struct ClientKeyExchange *clientkeyex = (struct ClientKeyExchange *) g_bytes_get_data(data, NULL);

gnutls_datum_t exkeys, pms;
exkeys.size = UINT16_INT(clientkeyex.length);
exkeys.data = (unsigned char *) &clientkeyex.exchange_keys;
exkeys.size = UINT16_INT(clientkeyex->length);
exkeys.data = (unsigned char *) &clientkeyex->pre_master_secret;
packet_tls_debug_print_hex("exchange keys", exkeys.data, exkeys.size);

packet_tls_privkey_decrypt_data(conn->server_private_key, 0, &exkeys, &pms);
Expand Down
7 changes: 1 addition & 6 deletions src/packet/packet_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,11 @@ struct PreMasterSecret
guint8 random[46];
};

struct EncryptedPreMasterSecret
{
guint8 pre_master_secret[128];
};

//! ClientKeyExchange type in Handshake records
struct ClientKeyExchange
{
uint16 length;
struct EncryptedPreMasterSecret exchange_keys;
guint8 pre_master_secret[];
};

/**
Expand Down

0 comments on commit 1b18bde

Please sign in to comment.