Commit dc6c17ca authored by Jorge Lopez Silva's avatar Jorge Lopez Silva Committed by Facebook Github Bot

Update utils to print out pre-shared secret.

Summary: This hadn't been updated since we moved to openssl 1.1

Reviewed By: knekritz

Differential Revision: D18668447

fbshipit-source-id: 26d58ef759fccf7e97c4d127b747b093077f6e59
parent 5a370151
...@@ -40,13 +40,10 @@ namespace ssl { ...@@ -40,13 +40,10 @@ namespace ssl {
bool OpenSSLUtils::getTLSMasterKey( bool OpenSSLUtils::getTLSMasterKey(
const SSL_SESSION* session, const SSL_SESSION* session,
MutableByteRange keyOut) { MutableByteRange keyOut) {
#if FOLLY_OPENSSL_IS_101 || FOLLY_OPENSSL_IS_102 #if FOLLY_OPENSSL_IS_110
if (session && auto size = SSL_SESSION_get_master_key(session, nullptr, 0);
session->master_key_length == static_cast<int>(keyOut.size())) { if (size == keyOut.size()) {
auto masterKey = session->master_key; return SSL_SESSION_get_master_key(session, keyOut.begin(), keyOut.size());
std::copy(
masterKey, masterKey + session->master_key_length, keyOut.begin());
return true;
} }
#else #else
(void)session; (void)session;
...@@ -58,12 +55,10 @@ bool OpenSSLUtils::getTLSMasterKey( ...@@ -58,12 +55,10 @@ bool OpenSSLUtils::getTLSMasterKey(
bool OpenSSLUtils::getTLSClientRandom( bool OpenSSLUtils::getTLSClientRandom(
const SSL* ssl, const SSL* ssl,
MutableByteRange randomOut) { MutableByteRange randomOut) {
#if FOLLY_OPENSSL_IS_101 || FOLLY_OPENSSL_IS_102 #if FOLLY_OPENSSL_IS_110
if ((SSL_version(ssl) >> 8) == TLS1_VERSION_MAJOR && ssl->s3 && auto size = SSL_get_client_random(ssl, nullptr, 0);
randomOut.size() == SSL3_RANDOM_SIZE) { if (size == randomOut.size()) {
auto clientRandom = ssl->s3->client_random; return SSL_get_client_random(ssl, randomOut.begin(), randomOut.size());
std::copy(clientRandom, clientRandom + SSL3_RANDOM_SIZE, randomOut.begin());
return true;
} }
#else #else
(void)ssl; (void)ssl;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment