How can I extract the secret key before using the OpenSSL wizard?

I have an application that I use for OpenSSL 1.0.2, and I would like to study traffic with Wireshark. Wireshark can (presumably) decrypt TLS conversations if you give it the secret of the pre-shared key.

If I use a cipher suite like TLS_RSA_WITH_AES_256_CBC_SHA256 ; can someone tell me how to get pre-master secret from SSL or SSL_CTX ? I'm fine with hacking opaque structures inside an SSL object - this is not what will be delivered in the product; I just want to know how to populate the secret pre-master file for Wireshark.

+6
source share
1 answer

I recommend using a master key that is easier to access. As far as I know, the pre-master key only exists ephemerally on the stack in OpenSSL. The master key is available in ssl_session_st (defined in ssl.h in the 1.0.2 branch, but ported to ssl_locl.h in a later version). The SSL member session element is a pointer to its ssl_session_st (aka SSL_SESSION ).

Wireshark can use a master key as well as a preliminary master key to decrypt connections. Here are the formats that Wireshark supports at the time of this writing:

  • RSA xxxx yyyy Where xxxx is the first 8 bytes of the encrypted pre-master secret (with hexadecimal encoding) Where yyyy is the pre-master secret key (hex-encoded) (this is the original format entered with error 4349)

  • RSA Session-ID:xxxx Master-Key:yyyy where xxxx is the SSL session identifier (with hexadecimal encoding) that nothing specific rsa about it.

  • PMS_CLIENT_RANDOM xxxx yyyy Where xxxx is the client_random from ClientHello (with hexadecimal encoding) Where yyyy is the secret key pre-master (hex-encoded) (This format allows you to decrypt SSL connections if the user can capture the ICP but cannot recover the MS for a specific session with the SSL server.)

  • CLIENT_RANDOM xxxx yyyy Where xxxx is the client_random from ClientHello (with hexadecimal encoding) Where yyyy is the secret plaintext key (with hexadecimal encoding) (This format allows you to decrypt SSL connections without RSA, i.e. ECDHE-RSA.)

Note that neither the primary key nor the primary key is a symmetric key (the title of the question implies that you might think that it is). The symmetric key is derived from the master key and random client / server data.

+6
source

All Articles